Package edu.uci.ics.jung.algorithms.util
Class Indexer
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.util.Indexer
-
public class Indexer extends java.lang.Object
A class providing static methods useful for improving the performance of graph algorithms.
-
-
Constructor Summary
Constructors Constructor Description Indexer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> org.apache.commons.collections4.BidiMap<T,java.lang.Integer>
create(java.util.Collection<T> collection)
Returns aBidiMap
mapping each element of the collection to its index as encountered while iterating over the collection.static <T> org.apache.commons.collections4.BidiMap<T,java.lang.Integer>
create(java.util.Collection<T> collection, int start)
Returns aBidiMap
mapping each element of the collection to its index as encountered while iterating over the collection.
-
-
-
Method Detail
-
create
public static <T> org.apache.commons.collections4.BidiMap<T,java.lang.Integer> create(java.util.Collection<T> collection)
Returns aBidiMap
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
-- Parameters:
collection
-- Returns:
- a bidirectional map from collection elements to 0-based indices
-
create
public static <T> org.apache.commons.collections4.BidiMap<T,java.lang.Integer> create(java.util.Collection<T> collection, int start)
Returns aBidiMap
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
-- Parameters:
collection
-start
- start index- Returns:
- a bidirectional map from collection elements to start-based indices
-
-