create generic stack swift programming

By | August 16, 2016

create generic stack swift programming

Swift has inbuilt generic data type Array and Dictionary. Here’s a simple example of a generic stack written in swift.

First we’ve created a generic stack that can create stack of any data type. push() function adds elements in stack and pop() takes them out.

In my custom stack I have given functions like count() that returns number of elements in stack and printElements() function prints all stack elements.


Leave a Reply

Your email address will not be published. Required fields are marked *