Class LazyVector

java.lang.Object
org.nuiton.math.matrix.LazyVector
All Implemented Interfaces:
Vector

public class LazyVector extends Object implements Vector
Cette classe encapsule un Vector et permet de l'initialiser reellement que lorsqu'on souhaite modifier une valeur. Cela permet de ne pas initialise d'enorme tableau s'il n'y en a pas besoin. Chaque lazy est initialisé avec un Vector non initialise, lorsque l'on fait un paste, si le vector a partir duquel on fait le paste est aussi un lazy, alors on partage le backend jusqu'a ce qu'un des deux vector veuille modifier une de ses valeurs.
Version:
$Revision$ Last update: $Date$ by : $Author$
Author:
poussin
  • Field Details

    • isInitBackend

      protected boolean isInitBackend
    • backend

      protected Vector backend
      reel backend, not initialized since not necessary
    • users

      protected AtomicInteger users
    • capacity

      protected long capacity
  • Constructor Details

    • LazyVector

      public LazyVector(Vector backend)
      Create new lazy, with initialized backend
      Parameters:
      backend -
    • LazyVector

      public LazyVector(Vector backend, long capacity)
      Create new lazy with not initialized backend
      Parameters:
      backend -
      capacity -
  • Method Details

    • 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
      Parameters:
      capacity -
    • 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:
    • 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
    • getMaxOccurence

      public double getMaxOccurence()
      Specified by:
      getMaxOccurence 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:
    • 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
    • size

      public long size()
      Specified by:
      size in interface Vector
    • 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 source)
      Description copied from interface: Vector
      Copie les valeurs du vector passé en argument dans ce vector.
      Specified by:
      paste in interface Vector
      Parameters:
      source - 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)
      Description copied from interface: Vector
      applique a chaque valeur du vector la MapFunction. ATTENTION cette function ne doit pas converser d'etat interne qui modifierait son comportement a chaque execution, sinon cette methode ne fonctionne pas, car pour les Vector implanter a base de Map la fonction n'est appliqué qu'au defaultValue et au valeur deja existante
      Specified by:
      map in interface Vector
      Parameters:
      f - funtion to apply
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      protected void prepareBackendForModification()
    • pasteToBackend

      protected void pasteToBackend(Vector target, Vector copy)
      Before call this method backend, must be initialized
      Parameters:
      target -
      copy -
    • 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é