Package edu.uci.ics.jung.algorithms.util
Class Indexer
java.lang.Object
edu.uci.ics.jung.algorithms.util.Indexer
A class providing static methods useful for improving the
performance of graph algorithms.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> com.google.common.collect.BiMap
<T, Integer> create
(Collection<T> collection) Returns aBiMap
mapping each element of the collection to its index as encountered while iterating over the collection.static <T> com.google.common.collect.BiMap
<T, Integer> create
(Collection<T> collection, int start) Returns aBiMap
mapping each element of the collection to its index as encountered while iterating over the collection.
-
Constructor Details
-
Indexer
public Indexer()
-
-
Method Details
-
create
Returns aBiMap
mapping each element of the collection to its index as encountered while iterating over the collection. The purpose of the index operation is to supply an O(1) replacement operation for the O(n)indexOf(element)
method of aList
- Type Parameters:
T
- the type of the collection elements- Parameters:
collection
- the collection whose indices are to be generated- Returns:
- a bidirectional map from collection elements to 0-based indices
-
create
public static <T> com.google.common.collect.BiMap<T,Integer> create(Collection<T> collection, int start) Returns aBiMap
mapping each element of the collection to its index as encountered while iterating over the collection. The purpose of the index operation is to supply an O(1) replacement operation for the O(n)indexOf(element)
method of aList
- Type Parameters:
T
- the type of the collection elements- Parameters:
collection
- the collection whose indices are to be generatedstart
- start index- Returns:
- a bidirectional map from collection elements to start-based indices
-