Class DoubleSparseArrayVector

  • All Implemented Interfaces:
    SparseVector, Vector

    public class DoubleSparseArrayVector
    extends Object
    implements SparseVector
    Permet de stocker des données à une position lineaire et de la redemander. Cette classe ne gére que les données lineaire. L'avantage de cette classe est de ne conserver que les elements differents de la valeur par defaut, ce qui minimize la taille du tableau necessaire a conserver les données. On permet que la matrice est plus de Integer.MAX_VALUE cellules mais on ne permet pas que la matrice est plus que Integer.MAX_VALUE valeur différente que le default value. Created: 6 octobre 2005 01:29:23 CEST
    Version:
    $Revision$ Last update: $Date$ by : $Author$
    Author:
    Benjamin POUSSIN <poussin@codelutin.com>
    • Field Detail

      • defaultValue

        protected double defaultValue
        la valeur par defaut
      • capacity

        protected long capacity
        maximum number of element, maximum pos value
      • assignedSize

        protected int assignedSize
        current number of assigned value
      • position

        protected long[] position
        contient la position de l'element, le tableau est trié
      • values

        protected double[] values
    • Constructor Detail

      • DoubleSparseArrayVector

        public DoubleSparseArrayVector()
      • DoubleSparseArrayVector

        public DoubleSparseArrayVector​(long capacity)
      • DoubleSparseArrayVector

        public DoubleSparseArrayVector​(long capacity,
                                       double defaultValue)
    • Method Detail

      • init

        public void init​(long capacity)
        Description copied from interface: Vector
        Init vector, before this method call, vector is in indetermined state. multiple call to init method must be permit. Only first call must do some work, extra call must do nothing
        Specified by:
        init in interface Vector
      • getInfo

        public String getInfo()
        Description copied from interface: Vector
        return information on this vector. This information depends on implementation example: - size - max occurence number - ...
        Specified by:
        getInfo in interface Vector
        Returns:
      • getDefaultValue

        public double getDefaultValue()
        Description copied from interface: SparseVector
        Value to used if not un assigned value
        Specified by:
        getDefaultValue in interface SparseVector
        Returns:
      • getAssignedPosition

        public long[] getAssignedPosition()
        Description copied from interface: SparseVector
        Return an orderer array of position assigned, this array can be longer than realy assigned value, you must used getNumberOfAssignedValue to know number of significant position in array
        Specified by:
        getAssignedPosition in interface SparseVector
        Returns:
      • getAssignedValue

        public double[] getAssignedValue()
        Description copied from interface: SparseVector
        Return an array in same order that getAssignedPosition. This array contains values. This array can be longer than realy assigned value, you must used getNumberOfAssignedValue to know number of significant position in array
        Specified by:
        getAssignedValue in interface SparseVector
        Returns:
      • getNumberOfAssignedValue

        public long getNumberOfAssignedValue()
        Description copied from interface: Vector
        Returne number of assigned value, assigned value is value stored in memory
        Specified by:
        getNumberOfAssignedValue in interface Vector
      • size

        public long size()
        Specified by:
        size in interface Vector
      • getMaxOccurrence

        public double getMaxOccurrence()
        Description copied from interface: Vector
        Retourne la valeur la plus utilise dans le vector
        Specified by:
        getMaxOccurrence in interface Vector
        Returns:
      • checkPos

        protected void checkPos​(long pos)
      • getValue

        public double getValue​(long pos)
        Specified by:
        getValue in interface Vector
      • setValue

        public void setValue​(long pos,
                             double value)
        Specified by:
        setValue in interface Vector
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • findIndex

        protected int findIndex​(long pos)
        retourne la position dans le tableau position de la position lineaire
        Parameters:
        pos -
        Returns:
        la position ou < 0 donnant la position de l'element s'il etait present
      • ensureCapacity

        protected void ensureCapacity​(int mincap)
      • addElementAt

        protected void addElementAt​(int index,
                                    long element,
                                    double value)
      • removeElementAt

        protected void removeElementAt​(int index)
      • isImplementedPaste

        public boolean isImplementedPaste​(Vector v)
        Description copied from interface: Vector
        Permet de savoir si paste est implanté par ce vector.
        Specified by:
        isImplementedPaste in interface Vector
        Parameters:
        v - vector to test
        Returns:
        true if operation is supported
      • isImplementedAdd

        public boolean isImplementedAdd​(Vector v)
        Description copied from interface: Vector
        Permet de savoir si add est implanté par ce vector.
        Specified by:
        isImplementedAdd in interface Vector
        Parameters:
        v - vector to test
        Returns:
        true if operation is supported
      • isImplementedMinus

        public boolean isImplementedMinus​(Vector v)
        Description copied from interface: Vector
        Permet de savoir si minus est implanté par ce vector.
        Specified by:
        isImplementedMinus in interface Vector
        Parameters:
        v - vector to test
        Returns:
        true if operation is supported
      • isImplementedMap

        public boolean isImplementedMap()
        Description copied from interface: Vector
        Permet de savoir si map est implanté par ce vector.
        Specified by:
        isImplementedMap in interface Vector
        Returns:
        true if operation is supported
      • paste

        public void paste​(Vector v)
        On recopie tous les attributs pour que le vector ressemble exactement a celui passé en argument
        Specified by:
        paste in interface Vector
        Parameters:
        v - vector to paste
      • add

        public void add​(Vector v)
        Description copied from interface: Vector
        Ajoute les valeurs du vector passé en argument a ce vector.
        Specified by:
        add in interface Vector
        Parameters:
        v - vector to add
      • minus

        public void minus​(Vector v)
        Description copied from interface: Vector
        Soustrait les valeurs du vector passé en argument a ce vector.
        Specified by:
        minus in interface Vector
        Parameters:
        v - vector to minus
      • map

        public void map​(MapFunction f)
        on applique sur chaque donnée existante et sur default
        Specified by:
        map in interface Vector
        Parameters:
        f - funtion to apply
      • iterator

        public VectorIterator iterator()
        Description copied from interface: Vector
        Retourne un objet Inc pret a etre utilisé pour boucler sur tous les element de la matrice.
        Specified by:
        iterator in interface Vector
        Returns:
        un objet Inc pret à être utilisé
      • iteratorNotZero

        public VectorIterator iteratorNotZero()
        Description copied from interface: Vector
        Retourne un objet Inc pret a etre utilisé pour boucler sur tous les element different de 0 de la matrice.
        Specified by:
        iteratorNotZero in interface Vector
        Returns:
        un objet Inc pret à être utilisé