Class IndexIdMaps


  • public class IndexIdMaps
    extends Object
    Static methods class for index-id maps.
    Author:
    Barak Ugav
    • Method Detail

      • indexToIdIterator

        public static <K> Iterator<K> indexToIdIterator​(IntIterator indexIter,
                                                        IndexIdMap<K> map)
        Create an IDs iterator from an iterator of indices.
        Type Parameters:
        K - the type of IDs
        Parameters:
        indexIter - an iterator of indices
        map - index-id mapping
        Returns:
        an iterator that iterate over the IDs matching the indices iterated by the original index-iterator
      • indexToIdIterator

        public static IntIterator indexToIdIterator​(IntIterator indexIter,
                                                    IndexIntIdMap map)
        Create an IDs iterator from an iterator of indices.
        Parameters:
        indexIter - an iterator of indices
        map - index-id mapping
        Returns:
        an iterator that iterate over the IDs matching the indices iterated by the original index-iterator
      • idToIndexIterator

        public static <K> IntIterator idToIndexIterator​(Iterator<K> idIter,
                                                        IndexIdMap<K> map)
        Create an indices iterator from an iterator of IDs.
        Type Parameters:
        K - the type of IDs
        Parameters:
        idIter - an iterator of IDs
        map - index-id mapping
        Returns:
        an iterator that iterate over the indices matching the IDs iterated by the original ID-iterator
      • indexToIdEdgeIter

        public static <V,​E> EdgeIter<V,​E> indexToIdEdgeIter​(Graph<V,​E> g,
                                                                        IEdgeIter indexIter)
        Create an IEdgeIter that return IDs of vertices and edges from an IEdgeIter that return indices of vertices and edges.
        Type Parameters:
        V - the vertices type
        E - the edges type
        Parameters:
        g - the graph
        indexIter - an IEdgeIter that return indices of vertices and edges
        Returns:
        IEdgeIter that return IDs of vertices and edges matching the indices of vertices and edges returned by the original index-iterator
      • indexToIdEdgeIter

        public static IEdgeIter indexToIdEdgeIter​(IntGraph g,
                                                  IEdgeIter indexIter)
        Create an IEdgeIter that return IDs of vertices and edges from an IEdgeIter that return indices of vertices and edges.
        Parameters:
        g - the graph
        indexIter - an IEdgeIter that return indices of vertices and edges
        Returns:
        IEdgeIter that return IDs of vertices and edges matching the indices of vertices and edges returned by the original index-iterator
      • indexToIdCollection

        public static <K> Collection<K> indexToIdCollection​(IntCollection indexCollection,
                                                            IndexIdMap<K> map)
        Create an IDs collection from a collection of indices.
        Type Parameters:
        K - the type of IDs
        Parameters:
        indexCollection - a collection of indices
        map - index-id mapping
        Returns:
        a collection that contain IDs matching the indices contained in the original index-collection
      • indexToIdCollection

        public static IntCollection indexToIdCollection​(IntCollection indexCollection,
                                                        IndexIntIdMap map)
        Create an int IDs collection from a collection of indices.
        Parameters:
        indexCollection - a collection of indices
        map - index-id mapping
        Returns:
        a collection that contain IDs matching the indices contained in the original index-collection
      • indexToIdSet

        public static <K> Set<K> indexToIdSet​(IntSet indexSet,
                                              IndexIdMap<K> map)
        Create an IDs set from a set of indices.
        Type Parameters:
        K - the type of IDs
        Parameters:
        indexSet - a set of indices
        map - index-id mapping
        Returns:
        a set that contain IDs matching the indices contained in the original index-set
      • indexToIdSet

        public static IntSet indexToIdSet​(IntSet indexSet,
                                          IndexIntIdMap map)
        Create an IDs set from a set of indices.
        Parameters:
        indexSet - a set of indices
        map - index-id mapping
        Returns:
        a set that contain IDs matching the indices contained in the original index-set
      • idToIndexCollection

        public static <K> IntCollection idToIndexCollection​(Collection<K> idCollection,
                                                            IndexIdMap<K> map)
        Create an indices collection from a collection of IDs.
        Type Parameters:
        K - the type of IDs
        Parameters:
        idCollection - a collection of IDs
        map - index-id mapping
        Returns:
        a collection that contain indices matching the IDs contained in the original ID-collection
      • idToIndexSet

        public static <K> IntSet idToIndexSet​(Set<K> idSet,
                                              IndexIdMap<K> map)
        Create an indices set from a set of IDs.
        Type Parameters:
        K - the type of IDs
        Parameters:
        idSet - a set of IDs
        map - index-id mapping
        Returns:
        a set that contain indices matching the IDs contained in the original ID-set
      • indexToIdList

        public static <K> List<K> indexToIdList​(IntList indexList,
                                                IndexIdMap<K> map)
        Create an IDs list from a list of indices.
        Type Parameters:
        K - the type of IDs
        Parameters:
        indexList - a list of indices
        map - index-id mapping
        Returns:
        a list that contain IDs matching the indices contained in the original index-list
      • indexToIdList

        public static IntList indexToIdList​(IntList indexList,
                                            IndexIntIdMap map)
        Create an IDs list from a list of indices.
        Parameters:
        indexList - a list of indices
        map - index-id mapping
        Returns:
        a list that contain IDs matching the indices contained in the original index-list
      • idToIndexWeights

        public static <K,​T,​WeightsT extends IWeights<T>> WeightsT idToIndexWeights​(Weights<K,​T> weights,
                                                                                               IndexIdMap<K> map)
        Create a weights view that is accessed by the elements indices, given a weights container that is accessed by the element IDs.

        The returned weights container is a view, namely modifying the original container change the new one, and vice versa.

        Type Parameters:
        K - the element (vertex or edge) identifiers type
        T - the weight type
        WeightsT - the weights container, used to avoid casts of containers of primitive types such as WeightsInt, WeightsDouble ect. The user should expect WeightsDouble only if a WeightsDouble object was passed as an argument.
        Parameters:
        weights - a weights container that is accessed by the elements IDs
        map - index-id map
        Returns:
        a weights-view that is accessed by the elements indices
      • idToIndexWeightFunc

        public static <K> IWeightFunction idToIndexWeightFunc​(WeightFunction<K> w,
                                                              IndexIdMap<K> map)
        Create a weight function that accept elements indices, given a weight function that accept elements IDs.
        Type Parameters:
        K - the type of elements IDs
        Parameters:
        w - a weight function that accept by elements IDs
        map - index-id map
        Returns:
        a weight function that accept elements indices
      • idToIndexWeightFunc

        public static <K> IWeightFunctionInt idToIndexWeightFunc​(WeightFunctionInt<K> w,
                                                                 IndexIdMap<K> map)
        Create an integer weight function that accept elements indices, given a weight function that accept elements IDs.
        Type Parameters:
        K - the type of elements IDs
        Parameters:
        w - an integer weight function that accept by elements IDs
        map - index-id map
        Returns:
        an integer weight function that accept elements indices