class Graphlb::DataStructures::Stack(A)

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Initializes the stack with empty Array


[View source]

Instance Method Detail

def empty? #

returns true if the stack is empty


[View source]
def pop #

pops the value that is last inserted

@return : last element inserted


[View source]
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


[View source]
def top #

returns the top-most element in the stack without deleting it.


[View source]
def values #

returns all the values that are present in the stack


[View source]