Documentation of 'mikera.indexz.Index' Java class
Index
mikera.indexz

Class Index

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AIndex>, java.lang.Iterable<java.lang.Integer>


    public final class Index
    extends AIndex
    Class to represent a mutable list of integer indexes, typically used for indexing into vectors or matrices. Backed by an int[] array.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      int[] data 
      static Index EMPTY 
    • Constructor Summary

      Constructors 
      Constructor and Description
      Index(int length) 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean allInRange(int start, int end)
      Checks that all values in this index are within the specified range of start (inclusive) to end (exclusive)
      AVector asVector() 
      Index clone() 
      Index compose(AIndex a)
      Composes this index with a second index, returning a new index.
      Index compose(Index a) 
      boolean containsSorted(int index)
      Returns true if the index contains a specific value.
      static Index create(AIndex index) 
      static Index create(java.util.ArrayList<java.lang.Integer> v)
      Creates an Index using the values from the given ArrayList.
      static Index create(AVector v)
      Creates an Index using the values from the given AVector.
      static Index create(int[] indices) 
      static Index create(java.util.List<java.lang.Integer> v)
      Creates an Index using the values from the given List.
      static Index createLength(int len)
      Create a new zero-filled Index with the specified length
      static Index createSorted(java.util.Set<java.lang.Integer> keySet) 
      static Index createSorted(java.util.SortedSet<java.lang.Integer> keySet) 
      boolean equals(Index o) 
      boolean equals(java.lang.Object o) 
      Index exactClone() 
      int find(int value)
      Finds a value in this Index and return's it's position, or -1 if not found
      int findMissing()
      Finds the first missing index value, assuming the index is sorted and distinct.
      int get(int i)
      Gets the index value at position i
      int[] getData() 
      int[] getShape() 
      Index includeSorted(Index ind) 
      Index includeSorted(java.util.Set<java.lang.Integer> is) 
      int indexPosition(int x)
      Looks up an index value in the index, returning its position or -1 if not found Index must be both sorted and distinct.
      Index insert(int position, int value)
      Returns a new Index with a value inserted at the specified position
      Index invert()
      Inverts the permutation represented by this Index
      boolean isDistinctSorted()
      Returns true if this index is distinct and sorted (in strictly increasing order)
      boolean isEvenPermutation() 
      boolean isFullyMutable() 
      boolean isOddPermutation() 
      boolean isPermutation()
      Returns true if this index represents a permutation of positions 0..length-1
      boolean isSorted()
      Returns true if this index is sorted (in increasing order)
      int last()
      Gets the last index value in this index.
      int length()
      Returns the length of this index list
      void lookupWith(Index source) 
      static Index of(int... indexes)
      Creates a new Index, using the specified index values
      void permute(Index permutationIndex)
      Permutes this vector according to a given permutation index
      void reverse()
      Reverses an index
      int seekPosition(int i)
      Returns the position at which an index value exists or should be inserted at in an index Index must be both sorted and distinct.
      void set(int i, int value) 
      void sort()
      Sorts the Index (in-place)
      void swap(int i, int j)
      Swaps (in-place) the indexes at two positions
      int swapCount()
      Counts the number of swaps required to create this permutation.
      int[] toArray() 
      java.util.Set<java.lang.Integer> toSet() 
      java.util.SortedSet<java.lang.Integer> toSortedSet() 
      int unsafeGet(int i) 
      static Index wrap(int[] indexes)
      Creates a new Index, wrapping the provided index array
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • EMPTY

        public static final Index EMPTY
      • data

        public final int[] data
    • Constructor Detail

      • Index

        public Index(int length)
    • Method Detail

      • create

        public static Index create(java.util.ArrayList<java.lang.Integer> v)
        Creates an Index using the values from the given ArrayList. Values are cast to integers as needed, according to the semantics of (int)value
        Parameters:
        v -
        Returns:
      • create

        public static Index create(java.util.List<java.lang.Integer> v)
        Creates an Index using the values from the given List. Values are cast to integers as needed, according to the semantics of (int)value
        Parameters:
        v -
        Returns:
      • create

        public static Index create(int[] indices)
      • createSorted

        public static Index createSorted(java.util.Set<java.lang.Integer> keySet)
      • createSorted

        public static Index createSorted(java.util.SortedSet<java.lang.Integer> keySet)
      • create

        public static Index create(AVector v)
        Creates an Index using the values from the given AVector. Values are cast to integers as needed, according to the semantics of (int)value
        Parameters:
        v -
        Returns:
      • wrap

        public static Index wrap(int[] indexes)
        Creates a new Index, wrapping the provided index array
      • of

        public static Index of(int... indexes)
        Creates a new Index, using the specified index values
      • createLength

        public static Index createLength(int len)
        Create a new zero-filled Index with the specified length
      • swap

        public void swap(int i,
                         int j)
        Swaps (in-place) the indexes at two positions
        Overrides:
        swap in class AIndex
      • reverse

        public void reverse()
        Reverses an index
        Overrides:
        reverse in class AIndex
      • isDistinctSorted

        public boolean isDistinctSorted()
        Description copied from class: AIndex
        Returns true if this index is distinct and sorted (in strictly increasing order)
        Overrides:
        isDistinctSorted in class AIndex
        Returns:
      • isSorted

        public boolean isSorted()
        Description copied from class: AIndex
        Returns true if this index is sorted (in increasing order)
        Overrides:
        isSorted in class AIndex
        Returns:
      • isPermutation

        public boolean isPermutation()
        Description copied from class: AIndex
        Returns true if this index represents a permutation of positions 0..length-1
        Overrides:
        isPermutation in class AIndex
        Returns:
      • includeSorted

        public Index includeSorted(java.util.Set<java.lang.Integer> is)
      • includeSorted

        public Index includeSorted(Index ind)
      • toSet

        public java.util.Set<java.lang.Integer> toSet()
      • toSortedSet

        public java.util.SortedSet<java.lang.Integer> toSortedSet()
      • swapCount

        public int swapCount()
        Counts the number of swaps required to create this permutation. The index must represent a permutation, or the behaviour is undefined.
        Returns:
      • isOddPermutation

        public boolean isOddPermutation()
      • isEvenPermutation

        public boolean isEvenPermutation()
      • get

        public int get(int i)
        Description copied from class: AIndex
        Gets the index value at position i
        Specified by:
        get in class AIndex
        Returns:
      • unsafeGet

        public int unsafeGet(int i)
      • set

        public void set(int i,
                        int value)
        Specified by:
        set in class AIndex
      • length

        public int length()
        Description copied from class: AIndex
        Returns the length of this index list
        Specified by:
        length in class AIndex
        Returns:
      • permute

        public void permute(Index permutationIndex)
        Permutes this vector according to a given permutation index
        Parameters:
        permutationIndex -
      • sort

        public void sort()
        Sorts the Index (in-place)
        Overrides:
        sort in class AIndex
      • asVector

        public AVector asVector()
      • equals

        public boolean equals(java.lang.Object o)
        Overrides:
        equals in class AIndex
      • equals

        public boolean equals(Index o)
      • getData

        public int[] getData()
      • toArray

        public int[] toArray()
        Overrides:
        toArray in class AIndex
      • lookupWith

        public void lookupWith(Index source)
      • compose

        public Index compose(AIndex a)
        Description copied from class: AIndex
        Composes this index with a second index, returning a new index. New index satisfies index.get(i) == a.get(this.get(i));
        Overrides:
        compose in class AIndex
        Returns:
      • indexPosition

        public int indexPosition(int x)
        Looks up an index value in the index, returning its position or -1 if not found Index must be both sorted and distinct.
        Specified by:
        indexPosition in class AIndex
        Parameters:
        x -
        Returns:
      • seekPosition

        public int seekPosition(int i)
        Description copied from class: AIndex
        Returns the position at which an index value exists or should be inserted at in an index Index must be both sorted and distinct.
        Overrides:
        seekPosition in class AIndex
        Returns:
        The target position in the index, which will satisfy 0 <= position <= this.length()
      • findMissing

        public int findMissing()
        Finds the first missing index value, assuming the index is sorted and distinct. If the index is a complete range, returns -1
        Returns:
      • containsSorted

        public boolean containsSorted(int index)
        Description copied from class: AIndex
        Returns true if the index contains a specific value. Assumes the index is in sorted order.
        Overrides:
        containsSorted in class AIndex
        Returns:
      • insert

        public Index insert(int position,
                            int value)
        Returns a new Index with a value inserted at the specified position
      • find

        public int find(int value)
        Finds a value in this Index and return's it's position, or -1 if not found
        Parameters:
        value -
        Returns:
      • invert

        public Index invert()
        Inverts the permutation represented by this Index
        Returns:
      • allInRange

        public boolean allInRange(int start,
                                  int end)
        Checks that all values in this index are within the specified range of start (inclusive) to end (exclusive)
        Parameters:
        start -
        end -
        Returns:
      • getShape

        public int[] getShape()
      • last

        public int last()
        Description copied from class: AIndex
        Gets the last index value in this index. Throws an exception if the index is empty
        Specified by:
        last in class AIndex
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.