Class TupleCollections
- Author:
- jhyde
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionasMemberArrayIterable
(TupleIterable tupleIterable) Converts aTupleIterable
to an old-style iterable that creates an iterator over member arrays.asMemberArrayList
(TupleList tupleList) Converts aTupleList
to an old-style list of member arrays.static TupleList
asTupleList
(List list) Converts an old-style list (members or member arrays) to aTupleList
.static TupleList
createList
(int arity) Creates a list of given arity.static TupleList
createList
(int arity, int initialCapacity) Creates a list of given arity and initial capacity.static TupleList
emptyList
(int arity) Returns an empty TupleList of given arity.static TupleIterator
iterator
(TupleCursor cursor) Adapts aTupleCursor
into aTupleIterator
.static TupleList
materialize
(TupleIterable tupleIterable, boolean eager) Converts aTupleIterable
into aTupleList
.slice
(TupleIterable tupleIterable, int column) Creates a slice of aTupleIterable
.static TupleList
unmodifiableList
(TupleList list) Creates an unmodifiable TupleList backed by a given list.
-
Method Details
-
createList
Creates a list of given arity.If arity == 1, creates a
UnaryTupleList
; if arity == 0, creates aDelegatingTupleList
; otherwise creates aArrayTupleList
.- Parameters:
arity
- Arity- Returns:
- Tuple list
- See Also:
-
createList
Creates a list of given arity and initial capacity.If arity == 1, creates a
UnaryTupleList
; if arity == 0, creates aDelegatingTupleList
; otherwise creates aArrayTupleList
.- Parameters:
arity
- ArityinitialCapacity
- Initial capacity- Returns:
- Tuple list
- See Also:
-
emptyList
Returns an empty TupleList of given arity.- Parameters:
arity
- Number of members per tuple- Returns:
- Empty tuple list
-
unmodifiableList
Creates an unmodifiable TupleList backed by a given list.- Parameters:
list
- the list for which an unmodifiable view is to be returned.- Returns:
- an unmodifiable view of the specified list.
- See Also:
-
iterator
Adapts aTupleCursor
into aTupleIterator
.Since the latter is a more difficult API to implement, the wrapper has some extra state.
This method may be used to implement
TupleIterable.tupleIterator()
for aTupleIterable
orTupleList
that only has aTupleCursor
implementation.- Parameters:
cursor
- Cursor- Returns:
- Tuple iterator view onto the cursor
-
slice
Creates a slice of aTupleIterable
.Can be used as an implementation for
TupleList.slice(int)
.- Parameters:
tupleIterable
- Iterablecolumn
- Which member of each tuple of project.- Returns:
- Iterable that returns a given member of each tuple
-
asMemberArrayIterable
Converts aTupleIterable
to an old-style iterable that creates an iterator over member arrays.- Parameters:
tupleIterable
- Tuple iterable- Returns:
- Iterable that creates an iterator over tuples represented as member arrays
-
asMemberArrayList
Converts aTupleList
to an old-style list of member arrays.- Parameters:
tupleList
- Tuple list- Returns:
- List of member arrays
-
asTupleList
Converts an old-style list (members or member arrays) to aTupleList
.Deduces the arity of the list from the first element, if the list is not empty. Otherwise assumes arity 1.
If the list happens to be a tuple list, returns unchanged.
- Parameters:
list
- Old-style list- Returns:
- Tuple list
-
materialize
Converts aTupleIterable
into aTupleList
.If the iterable is already a list, returns the iterable. If it is not a list, the behavior depends on the
eager
parameter. With eager = true, creates a list and populates it with the contents of the iterable. With eager = false, wraps in an adapter that implements the list interface and materializes to a list the first time that an operation that is in TupleList but not TupleIterable -- for example,TupleList.get(int, int)
orList.size()
-- is called.- Parameters:
tupleIterable
- Iterableeager
- Whether to convert into a list now, as opposed to on first use of a random-access method such as size or get.- Returns:
- List
-