An ADT signature is the description of the characteristics of an ADT, such as it’s operations. Most ADT Signatures define:
- A constructor, to create the ADT
- Methods to add and remove elements
- A boolean method to check if the ADT is full/empty
- A method to ‘get’ an element
length: ADT → int
isFull: ADT → bool
isEmpty: ADT → bool
Lists
Signature
Link to sourcename: list import: element, boolean ops: newList : → list; first : list → element; rest : list → list; insert : list × element → list; contains : list × element → boolean; append : list × element → list; isEmpty : list → boolean; etc. (more operations can be defined)
Arrays
Signature
Link to sourcename: Array import: element,int,bool ops: newArray: → Array append: Array x element x int → Array get: Array x int -element isEmpty/isFull: Array → bool length: Array → int
Sets
[status: TODO]
Signature
Link to sourcename: Set import: element, int, bool ops:
Stacks
Signature
Link to sourcename stack; import elem, boolean; ops: newStack : → stack; push : stack × elem → stack; pop : stack → stack; top : stack → elem; isEmpty : stack → boolean; etc.
Queues
Signature
Link to sourcename queue; import elem, boolean; ops: newQueue : → queue; enqueue : queue × elem → queue; dequeue : queue → queue; front : queue → elem; isEmpty : queue → boolean; etc.
Priority Queues
Signature
Link to sourcename PQueue; import element; ops: newPQueue : → PQueue; enqueue : PQueue × element × integer → PQueue; head : PQueue → element; dequeue: PQueue → PQueue; isFull : PQueue → boolean; etc.
Dictionaries
Signature
Link to sourcename Dictionary; import key, value, integer, boolean; ops: newDict : → dictionary; insert : dictionary × key × value → dictionary; inDict : dictionary × key → boolean; remove : dictionary × key → dictionary; lookup : dictionary × key → value; update : dictionary × key × value → dictionary; length : dictionary → integer;
Graphs
Signature
Link to sourcename: graph; import node, edge, list, integer, boolean; ops: newGraph:→ graph; allNodes:graph → list; allEdges:graph → list; addNode:graph × node → graph; deleteNode:graph × node → graph; NodeExists:graph × node → boolean; addEdge:graph × edge → graph; deleteEdge:graph × edge → graph; EdgeExists:graph × edge → boolean; neighbours:graph × node → list; startNode:edge → node; endNode:edge → node; incident:graph × node → list;