tango.util.collection.model.SeqView

interface SeqView(T) : View!(T) #
Seqs are indexed, sequentially ordered collections. Indices are always in the range 0 .. size() -1. All accesses by index are checked, raising exceptions if the index falls out of range.

The elements() enumeration for all seqs is guaranteed to be traversed (via nextElement) in sequential order.

Author:

Doug Lea @version 0.93

For an introduction to this package see Overview .

T get(int index) [public] #
Return the element at the indicated index @param index

Returns:

the element at the index

Throws:

NoSuchElementException if index is not in range 0..size()-1
T head() [public] #
Return the first element, if it exists. Behaviorally equivalent to at(0)

Throws:

NoSuchElementException if isEmpty
T tail() [public] #
Return the last element, if it exists. Behaviorally equivalent to at(size()-1)

Throws:

NoSuchElementException if isEmpty
int first(T element, int startingIndex = 0) [public] #
Report the index of leftmost occurrence of an element from a given starting point, or -1 if there is no such index. @param element the element to look for @param startingIndex the index to start looking from. The startingIndex need not be a valid index. If less than zero it is treated as 0. If greater than or equal to size(), the result will always be -1.

Returns:

index such that
 
 let int si = max(0, startingIndex) in
  index == -1 &&
   foreach (int i in si .. size()-1) !at(index).equals(element)
  ||
  at(index).equals(element) &&
   foreach (int i in si .. index-1) !at(index).equals(element)
 
int last(T element, int startingIndex = 0) [public] #
Report the index of righttmost occurrence of an element from a given starting point, or -1 if there is no such index. @param element the element to look for @param startingIndex the index to start looking from. The startingIndex need not be a valid index. If less than zero the result will always be -1. If greater than or equal to size(), it is treated as size()-1.

Returns:

index such that
 
 let int si = min(size()-1, startingIndex) in
  index == -1 &&
   foreach (int i in 0 .. si) !at(index).equals(element)
  ||
  at(index).equals(element) &&
   foreach (int i in index+1 .. si) !at(index).equals(element)
 
SeqView subset(int index, int length) [public] #
Construct a new SeqView that is a clone of self except that it does not contain the elements before index or after index+length. If length is less than or equal to zero, return an empty SeqView. @param index of the element that will be the 0th index in new SeqView @param length the number of elements in the new SeqView

Returns:

new seq such that
 s.size() == max(0, length) &&
 foreach (int i in 0 .. s.size()-1) s.at(i).equals(at(i+index)); 
 

Throws:

NoSuchElementException if index is not in range 0..size()-1
SeqView opSlice(int begin, int end) [public] #
Construct a new SeqView that is a clone of self except that it does not contain the elements before begin or after end-1. If length is less than or equal to zero, return an empty SeqView. @param index of the element that will be the 0th index in new SeqView @param index of the last element in the SeqView plus 1

Returns:

new seq such that
 s.size() == max(0, length) &&
 foreach (int i in 0 .. s.size()-1) s.at(i).equals(at(i+index)); 
 

Throws:

NoSuchElementException if index is not in range 0..size()-1