Class CyclicVector

java.lang.Object
java.util.AbstractCollection<Object>
java.util.AbstractList<Object>
java.util.Vector<Object>
org.episteme.natural.chemistry.loaders.cml.util.CyclicVector
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess, SequencedCollection<Object>

public class CyclicVector extends Vector<Object>
a 'cyclic vector' that is element[0] succeeds element[nElem-1] where nElem is size. Provides elements(startIndex) as Enumeration which iterates through whole of Vector cyclicly. [Normal elements() is inherited from Vector and starts from element[0]]. This class is not thread-safe. The vector and its contents can be changed but Enumerations will be invalidated.
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Constructor Details

    • CyclicVector

      public CyclicVector()
      create with an empty vector
    • CyclicVector

      public CyclicVector(Vector<?> vector)
      Creates a new CyclicVector from an existing vector.
      Parameters:
      vector - the vector to copy elements from
  • Method Details

    • elements

      public Enumeration<Object> elements(Object startObject) throws IllegalArgumentException
      Creates an Enumeration starting with the first element that contains startObject.
      Parameters:
      startObject - the object to start the iteration from
      Returns:
      a cyclic enumeration of the vector's elements
      Throws:
      IllegalArgumentException - if the startObject is not found in the vector
    • elements

      public Enumeration<Object> elements(int startIndex) throws IllegalArgumentException
      Creates an Enumeration starting at the specified index.
      Parameters:
      startIndex - the index to start the iteration from
      Returns:
      a cyclic enumeration of the vector's elements
      Throws:
      IllegalArgumentException - if the startIndex is out of bounds
    • main

      public static void main(String[] args)
      Test main method for CyclicVector.
      Parameters:
      args - command line arguments: size and start index