Jump to content
Sign in to follow this  
lynkfs@gmail.com

data structures

Recommended Posts

Some data structures,

derived directly from TObject :

 

TSet

"A data type that can store values without any particular order and no double ups" (wikipedia)

    Procedure   Add(Item: Variant);
    Procedure   Remove(Item: Variant);
    Function      Contains(Item: Variant): Variant;
    Function      Union(Set: TSet): TSet;
    Function      Intersect(Set: TSet): TSet;
    Function      Difference(Set: TSet): TSet;

 

 

TStack (LIFO)

"A collection of elements. Push adds an element to the collection and pop removes the most recent added element. Alternatively called LIFO (last in first out)." Wikipedia.

    Procedure   Push(Item: Variant);
    Function      Pop: Variant;
    Function      Peek: Variant;

 

 

TQueue (FIFO)

"A collection of elements maintained in order. Enqueue adds elements to the rear and dequeue removes elements from the front. Hence FIFO (first in, first out)." Wikipedia

    Procedure   Enqueue(Item: Variant);
    Function      Dequeue: Variant;
    Function      Peek: Variant;

 

 

TArray

"A collection of elements identified by at least one index or key." Wikipedia

    Procedure   Add(Item: Variant);
    Procedure   RemoveValue(Item: Variant);
    Procedure   RemoveIndex(Item: Variant);
    Function      LookUpValue(Item:Variant): Variant;
    Function      LookUpIndex(Item:Variant): Variant;
 
 

Inspired in part by work done by Scott Ladd and Benoit Vallon

 

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×