Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit BinTree;
- interface
- uses System.SysUtils, System.Types, Generics.Collections;
- type
- TNodeCoords = TList<TPoint>;
- type
- TComparator<TKey> = function(const A, B: TKey): ShortInt;
- // negatiive: A < B; zero: A = B; positive: A > B
- TBinaryTree<K, V> = class
- private type
- PNode = ^TNode;
- TNode = record
- Value: V;
- Key: K;
- PLeft, PRight: PNode;
- constructor Create(const Key: K; const Value: V);
- end;
- function GetPreviousNode(const Key: K): PNode;
- function GetPreReplaceNode(startNode: PNode): PNode;
- function GetNodeCoords(Node: PNode): TNodeCoords;
- var
- FCount: Integer;
- Comparator: TComparator<K>;
- PHead: PNode;
- public
- constructor Create(Comparator: TComparator<K>);
- property Count: Integer read FCount;
- procedure Add(const Key: K; const Value: V);
- procedure Delete(const Key: K);
- end;
- implementation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement