Stack - acadet/ludivine GitHub Wiki
Stack<T>
|> ISortableCollection<T>
|> ICollection<T>
A classic stack structure (FILO).
NB: Browsers always move from newest to oldest elements.
Stack<T>()
Builds new stack.
Stack<T>(source : ICollection<T>)
Builds new stack.
Parameters
source Data source
average(getter : Func<T, number>) : number
Inherited from ICollection.
exists(selector : Func<T, boolean>) : boolean
Inherited from ICollection.
find(selector : Func<T, boolean>) : T
Inherited from ICollection.
forEach(action : Action<T>) : void
Inherited from ICollection.
getSize() : number
Returns current size.
intersect(collection : ICollection<T>) : ICollection<T>
Inherited from ICollection.
map(action : Func<T, T>) : ICollection<T>
Inherited from ICollection.
max(getter : Func<T, number>) : T
Inherited from ICollection.
min(getter : Func<T, number>) : T
Inherited from ICollection.
orderBy<U>(getter : Func<T, U>) : ISortableCollection<T>
Inherited from ISortableCollection.
Ordering stack produces a new stack where newest element is the lowest.
Example
stack.push(56);
stack.push(45);
stack.push(47);
orderedStack = stack.orderBy(x => x);
// orderedStack = 56 | 47 | 45
// orderedStack.top() = 45
orderByDesc<U>(getter : Func<T, U>) : ISortableCollection<T>
Inherited from ISortableCollection.
Ordering stack using descending method produces a stack where newest element is the greatest.
Example
stack.push(56);
stack.push(45);
stack.push(47);
orderedStack = stack.orderByDesc(x => x);
// orderedStack = 45 | 47 | 56
// orderedStack.top() = 56
pop() : T
Gets newest element and removes it from stack.
push(value : T) : void
Adds new value to stack.
Parameters
value Value
reverse() : ISortableCollection<T>
Inherited from ISortableCollection.
select(selector : Func<T, boolean>) : ICollection<T>
Inherited from ICollection.
sum(getter : Func<T, number>) : number
Inherited from ICollection.
toArray() : Array<T>
Inherited from ICollection.
Array first element is newest element of stack.
Example
stack.push('foo');
stack.push('bar');
stack.push('barbar');
a = stack.toArray() // barbar | bar | foo
toDictionary<K, V>(keyGetter : Func<T, K>, valueGetter : Func<T, V>) : IDictionary<K, V>
Inherited from ICollection.
toList() : IList<T>
Inherited from ICollection.
List first element is newest element of stack.
Example
stack.push('foo');
stack.push('bar');
stack.push('barbar');
l = stack.toList() // barbar | bar | foo
top() : T
Gets newest element without removing it from stack.
union(collection : ICollection<T>) : ICollection<T>
Inherited from ICollection.
Unifies using collection browser.
Example
s1.push(10);
s1.push(11);
s2.push(20);
s2.push(21);
s3 = s1.union(s2); // 10 | 11 | 21 | 20
// s3.top() = 20
uniq() : ICollection<T>
Inherited from ICollection.
Removes duplicates from oldest to newest.
Example
s.push(10);
s.push(11);
s.push(11);
s.push(12);
s.push(10);
t = s.uniq(); // 10 | 11 | 12
// t.top() = 12