Jump to content


Photo

data structures

set stack queue array

  • Please log in to reply
No replies to this topic

#1 Nico Wouterse

Nico Wouterse
  • Moderators
  • 262 posts
  • LocationAustralia

Posted 24 November 2016 - 03:23 PM

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

 

 

 

 


  • ielite, BobLawrence and Igor Savkic like this
Nico Wouterse





Also tagged with one or more of these keywords: set, stack, queue, array

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users