Class TupleCollections
- Author:
- jhyde
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionasMemberArrayIterable(TupleIterable tupleIterable) Converts aTupleIterableto an old-style iterable that creates an iterator over member arrays.asMemberArrayList(TupleList tupleList) Converts aTupleListto an old-style list of member arrays.static TupleListasTupleList(List list) Converts an old-style list (members or member arrays) to aTupleList.static TupleListcreateList(int arity) Creates a list of given arity.static TupleListcreateList(int arity, int initialCapacity) Creates a list of given arity and initial capacity.static TupleListemptyList(int arity) Returns an empty TupleList of given arity.static TupleIteratoriterator(TupleCursor cursor) Adapts aTupleCursorinto aTupleIterator.static TupleListmaterialize(TupleIterable tupleIterable, boolean eager) Converts aTupleIterableinto aTupleList.slice(TupleIterable tupleIterable, int column) Creates a slice of aTupleIterable.static TupleListunmodifiableList(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 aTupleCursorinto 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 aTupleIterableorTupleListthat only has aTupleCursorimplementation.- 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 aTupleIterableto 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 aTupleListto 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 aTupleIterableinto aTupleList.If the iterable is already a list, returns the iterable. If it is not a list, the behavior depends on the
eagerparameter. 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
-