-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
FieldIndex.java
72 lines (64 loc) · 2.33 KB
/
FieldIndex.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/
package alluxio.collections;
import java.util.Set;
/**
* An interface representing an index for this {@link IndexedSet}, 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 of {@link IndexedSet} to represent the same index.
*
* @param <T> type of objects in this {@link IndexedSet}
*/
interface FieldIndex<T> {
// /**
// * Gets the value of the field that serves as index.
// *
// * @param o the instance to get the field value from
// * @return the field value, which is just an Object
// */
// Object getFieldValue(T o);
/**
* Puts the an object o to the index.
*
* @param o the instance to get the field value from
*/
void add(T o);
/**
* Remove the object o from the index.
*
* @param o the instance to get the field value from
* @return true if success, false if this set did not already contain the specified element
*/
boolean remove(T o);
/**
* Whether there is an object with the specified index field value in the set.
*
* @param value the field value
* @return true if there is one such object, otherwise false
*/
boolean contains(Object value);
/**
* Gets a subset of objects with the specified field value. If there is no object with
* the specified field value, a newly created empty set is returned.
*
* @param value the field value to be satisfied
* @return the set of objects or an empty set if no such object exists
*/
Set<T> getByField(Object value);
/**
* Gets an object from the set of objects with the specified unique field value.
*
* @param value the field value
* @return the object or null if there is no such object
*/
T getFirst(Object value);
}