Stack
class Stack implements Collection, ArrayAccess (View source)
A Stack is a “last in, first out” or “LIFO” collection that only allows access to the value at the top of the structure and iterates in that order, destructively.
Methods
Creates a new instance, using either a traversable object or an array for the initial values.
Ensures that enough memory is allocated for a required capacity. This removes the need to reallocate the internal as values are added.
Returns the current capacity.
Removes all values from the stack.
Count elements of an object
Returns a shallow copy of the collection.
No description
Returns whether the collection is empty.
Converts the collection to an array.
Specify data which should be serialized to JSON
Returns the value at the top of the stack, but does not remove it.
Removes and returns the value at the top of the stack.
Pushes values onto the stack.
No description
No description
No description
No description
Details
__construct(TValue> $values = [])
Creates a new instance, using either a traversable object or an array for the initial values.
allocate(int $capacity)
Ensures that enough memory is allocated for a required capacity. This removes the need to reallocate the internal as values are added.
int
capacity()
Returns the current capacity.
void
clear()
Removes all values from the stack.
int
count()
Count elements of an object
TValue>
copy()
Returns a shallow copy of the collection.
Traversable
getIterator()
No description
bool
isEmpty()
Returns whether the collection is empty.
array
toArray()
Converts the collection to an array.
Note: Casting to an array is not supported yet.
mixed
jsonSerialize()
Specify data which should be serialized to JSON
TValue
peek()
Returns the value at the top of the stack, but does not remove it.
TValue
pop()
Removes and returns the value at the top of the stack.
push(TValue ...$values)
Pushes values onto the stack.
bool
offsetExists(TKey $offset)
No description
mixed
offsetGet(TKey $offset)
No description
void
offsetSet(TKey $offset, TValue $value)
No description
void
offsetUnset(TKey $offset)
No description