Package alluxio.collections
Interface FieldIndex<T,V>
-
- Type Parameters:
T
- type of objects in this indexV
- type of the field used for indexing
- All Superinterfaces:
java.lang.Iterable<T>
- All Known Implementing Classes:
NonUniqueFieldIndex
,UniqueFieldIndex
public interface FieldIndex<T,V> extends java.lang.Iterable<T>
An interface representing an index forIndexedSet
, each index for this set must implement the interface to define how to get the value of the field chosen as the index. Users must use the same instance of the implementation of this interface as the parameter in all methods ofIndexedSet
to represent the same index.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
add(T o)
Adds an object o to the index.void
clear()
Removes all the entries in this index.boolean
containsField(V fieldValue)
Returns whether there is an object with the specified index field value in the set.boolean
containsObject(T o)
Returns whether there is an object in the set.java.util.Set<T>
getByField(V value)
Gets a subset of objects with the specified field value.T
getFirst(V value)
Gets an object from the set of objects with the specified field value.java.util.Iterator<T>
iterator()
Returns an iterator over the elements in this index.boolean
remove(T o)
Removes the object o from the index.int
size()
-
-
-
Method Detail
-
add
boolean add(T o)
Adds an object o to the index.- Parameters:
o
- the object to add to the index- Returns:
- true if object is added successfully, false otherwise
-
remove
boolean remove(T o)
Removes the object o from the index.- Parameters:
o
- the object to remove from index- Returns:
- whether the specified element was in the index
-
clear
void clear()
Removes all the entries in this index.
-
containsField
boolean containsField(V fieldValue)
Returns whether there is an object with the specified index field value in the set.- Parameters:
fieldValue
- the field value to be satisfied- Returns:
- true if there is one such object, otherwise false
-
containsObject
boolean containsObject(T o)
Returns whether there is an object in the set.- Parameters:
o
- the object to be checked- Returns:
- true if there is one such object, otherwise false
-
getByField
java.util.Set<T> getByField(V value)
Gets a subset of objects with the specified field value. If there is no object with the specified field value, an empty set is returned.- Parameters:
value
- the field value to be satisfied- Returns:
- the set of objects or an empty set if no such object exists
-
getFirst
T getFirst(V value)
Gets an object from the set of objects with the specified field value.- Parameters:
value
- the field value to be satisfied- Returns:
- the object or null if there is no such object
-
iterator
java.util.Iterator<T> iterator()
Returns an iterator over the elements in this index. The elements are returned in no particular order. Note that the behavior of the iterator is unspecified if the underlying collection is modified while a thread is going through the iterator.- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Returns:
- an iterator over the elements in this
FieldIndex
-
size
int size()
- Returns:
- the number of objects in this index set
-
-