A List
which can be efficiently searched for
occurrences of a given element, or for inclusions of a
given sublist of elements. This interface provides
operations for finding:
Occurrences and inclusions are identified by a list index at which the value or sublist of values occurs in the list. In the case of an inclusion, it is the index of the first matching value from the sublist.
Inclusions may overlap. For example:
"yoyoyoyoyo".inclusions("yoy")
produces the stream { 0, 2, 4, 6 }
.
An empty list is considered to be included at every index,
including the index List.size
at the very end of the
list. Thus:
"hello".inclusions("")
produces the stream { 0, 1, 2, 3, 4, 5 }
, with 6
inclusions in a string of length 5.
In particular:
"".inclusions("x")
is the empty stream {}
, but"".inclusions("")
is the stream { 0 }
.no type hierarchy
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Collection<Element> |
Attributes inherited from: Correspondence<Key,Item> |
Attributes inherited from: Iterable<Element,Absent> |
Attributes inherited from: List<Element> |
Methods | |
firstInclusion | Source Codeshared default Integer? firstInclusion(List<Element> sublist, Integer from = 0) The first index in this list at which the given list occurs as a sublist, that is greater than or equal to the optional starting index. Parameters:
|
firstOccurrence | Source Codeshared default Integer? firstOccurrence(Element element, Integer from = 0, Integer length = ...) The first index in this list at which the given
value occurs, that falls within the segment
Parameters:
|
includes | Source Codeshared default Boolean includes(List<Element> sublist, Integer from = 0) Determine if the given list occurs as a sublist at some index in this list, at any index that is greater than or equal to the optional starting index. Parameters:
|
includesAt | Source Codeshared default Boolean includesAt(Integer index, List<Element> sublist) |
inclusions | Source Codeshared default {Integer*} inclusions(List<Element> sublist, Integer from = 0) The indexes in this list at which the given list occurs as a sublist, that are greater than or equal to the optional starting index. Parameters:
|
lastInclusion | Source Codeshared default Integer? lastInclusion(List<Element> sublist, Integer from = 0) The last index in this list at which the given
list occurs as a sublist, that falls within
the range Parameters:
|
lastOccurrence | Source Codeshared default Integer? lastOccurrence(Element element, Integer from = 0, Integer length = ...) The last index in this list at which the given
value occurs, that falls within the range
Parameters:
|
occurrences | Source Codeshared default {Integer*} occurrences(Element element, Integer from = 0, Integer length = ...) The indexes in this list at which the given value occurs. Parameters:
|
occurs | Source Codeshared default Boolean occurs(Element element, Integer from = 0, Integer length = ...) Determines if the given value occurs as an
element of this list, at any index that falls within
the segment Parameters:
|
occursAt | Source Codeshared default Boolean occursAt(Integer index, Element element) Determines if the given value occurs at the given index in this list. Parameters:
|