Package org.apache.cassandra.locator
Interface ReplicaCollection<C extends ReplicaCollection<C>>
- All Known Subinterfaces:
ReplicaCollection.Builder<C>
- All Known Implementing Classes:
AbstractReplicaCollection,Endpoints,EndpointsForRange,EndpointsForRange.Builder,EndpointsForToken,EndpointsForToken.Builder,RangesAtEndpoint,RangesAtEndpoint.Builder
A collection like class for Replica objects. Represents both a well defined order on the contained Replica objects,
and efficient methods for accessing the contained Replicas, directly and as a projection onto their endpoints and ranges.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceReplicaCollection.Builder<C extends ReplicaCollection<C>>A mutable (append-only) extension of a ReplicaCollection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintbooleanfilterLazily(Predicate<? super Replica> predicate) filterLazily(Predicate<? super Replica> predicate, int maxSize) get(int i) inthashCode()booleanisEmpty()iterator()intsize()sorted(Comparator<? super Replica> comparator) stream()subList(int start, int end) toString()Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
endpoints
Set<InetAddressAndPort> endpoints()- Returns:
- a Set of the endpoints of the contained Replicas. Iteration order is maintained where there is a 1:1 relationship between endpoint and Replica Typically this collection offers O(1) access methods, and this is true for all but ReplicaList.
-
get
- Parameters:
i- a value in the range [0..size())- Returns:
- the i'th Replica, in our iteration order
-
size
int size()- Returns:
- the number of Replica contained
-
isEmpty
boolean isEmpty()- Returns:
- true iff size() == 0
-
contains
- Returns:
- true iff a Replica in this collection is equal to the provided Replica. Typically this method is expected to take O(1) time, and this is true for all but ReplicaList.
-
count
- Returns:
- the number of replicas that match the predicate
-
filter
- Returns:
- a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
filter
- Returns:
- a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result. Only the first maxSize items will be returned.
-
filterLazily
- Returns:
- a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate.
-
filterLazily
- Returns:
- a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate. Only the first maxSize matching items will be returned.
-
subList
- Returns:
- an *eagerly constructed* copy of this collection containing the Replica at positions [start..end); An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
sorted
- Returns:
- an *eagerly constructed* copy of this collection containing the Replica re-ordered according to this comparator It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
iterator
- Specified by:
iteratorin interfaceIterable<C extends ReplicaCollection<C>>
-
stream
-
equals
-
hashCode
int hashCode() -
toString
String toString()
-