|Returns the first element of the sequence, or nil if the sequence is empty.|
|Returns the last element of the sequence, or nil if the sequence is emtpty.|
|Calls sequence:removeElement(e) for e in iter(elements).|
|Removes the first instance of element from sequence and returns it, or if not found, nil.|
|Permutes the input sequence in place, using the optionally supplied rng (by default math.random).|
|Sorts the sequence in place using the built-in table.sort function and the ordering specified (default is increasing order).|
|Exchanges the elements stored in sequence at the two supplied indices.|
|Returns a string representation of sequence.|
rng can be any function which can takes two integer arguments a,b and returns a random integer in the range [a..b] (inclusive on both sides).
The algorithm runs in linear time and generates all permutations with equal probability, assuming the rng is perfectly uniform. It is implemented using an algorithm proposed by Knuth, see http://en.wikipedia.org/wiki/Shuffle#Shuffling_algorithms
If seq is a Vector or Tuple, no auxilliary table is created for the sort. If seq is any other collection, a copy of seq is created, sorted, and the results copied back to seq.
sequences.swap(sequence, index1, index2)
This method is used for the __tostring metamethod of Vector, SkipVector, QueueVector, and LinkedList. Example:
> print(SkipVector:make(1,2,3,4,5)) [1, 2, 3, 4, 5]