Class IntVec

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Integer>

    public final class IntVec
    extends java.lang.Object
    implements java.lang.Iterable<java.lang.Integer>
    low level, efficient int vector
    Version:
    4.7
    • Constructor Summary

      Constructors 
      Constructor Description
      IntVec​(MemoryPool pool)
      initializes the array with a memory pool
      IntVec​(MemoryPool pool, java.lang.Iterable<java.lang.Integer> clause)
      initialize from pool and some integers
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int i)
      add an element at the end of the array
      void clear()
      clears all elements in the array
      int get​(int index)  
      boolean isEmpty()
      checks if the array contains elements
      java.util.Iterator<java.lang.Integer> iterator()  
      void remove​(int index)
      remove the element at index index
      void removeFast​(int index)
      this removes the element at given index.
      void set​(int index, int i)
      set the element at index index to i
      int size()
      number of elements
      int[] toArray()
      get a new array from the clause
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • array

        public int[] array
      • numElem

        public int numElem
    • Constructor Detail

      • IntVec

        public IntVec​(MemoryPool pool)
        initializes the array with a memory pool
        Parameters:
        pool - the pool to use for memory allocation
      • IntVec

        public IntVec​(MemoryPool pool,
                      java.lang.Iterable<java.lang.Integer> clause)
        initialize from pool and some integers
        Parameters:
        pool - the pool to use
        clause - the elements to add
    • Method Detail

      • add

        public void add​(int i)
        add an element at the end of the array
        Parameters:
        i - the element to add
      • clear

        public void clear()
        clears all elements in the array
      • isEmpty

        public boolean isEmpty()
        checks if the array contains elements
        Returns:
        true if the array is empty
      • get

        public int get​(int index)
      • set

        public void set​(int index,
                        int i)
        set the element at index index to i
        Parameters:
        index - the index to modify
        i - the new value
      • size

        public int size()
        number of elements
        Returns:
        number of elements in the vector
      • remove

        public void remove​(int index)
        remove the element at index index
        Parameters:
        index - the index of the element to remove
      • removeFast

        public void removeFast​(int index)
        this removes the element at given index. This operation does *NOT* keep the order in the array (the last element may change of position)
        Parameters:
        index - the index to remove
      • toArray

        public int[] toArray()
        get a new array from the clause
        Returns:
        a new array
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • iterator

        public java.util.Iterator<java.lang.Integer> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Integer>