class Graphlb::DataStructures::Stack(A)
- Graphlb::DataStructures::Stack(A)
- Reference
- Object
Overview
In crystal, elements in an array are added in dynamics fashion means the size of the array is not fixed which makes them quite similar to linked list.
Here we have implemanted the stack data-structure using an array.A stack follows Last-in-First-out.
Defined in:
graphlb/data_structures/stack.crConstructors
-
.new
Initializes the stack with empty Array
Instance Method Summary
-
#empty?
returns true if the stack is empty
-
#pop
pops the value that is last inserted
-
#push(val)
pushes the value present inside the val into the stack
-
#top
returns the top-most element in the stack without deleting it.
-
#values
returns all the values that are present in the stack
Constructor Detail
Instance Method Detail
def push(val)
#
pushes the value present inside the val into the stack
@param : val , the value we want to append into the stack
@return : returns the array of elements in the stack