Jump to content

data structures


Recommended Posts

  • Moderators

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

 

 

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...