Skip to content

JBontes/DelphiSpringTrees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DelphiSpringTrees

Trees in Spring4D

#Trees are a much needed feature in any toolkit.
Delphi generics.collections does not have any trees and neither does Spring4D.
To remedy this omision here is a modest proposal for efficient generic trees.

Trees contains:

  • TRedBlackTree<K> : Left-leaning red black tree
  • TRedBlackTree<K,V> : Left-leaning red-black tree, can serve as a replacement for TDictionary

All classes are written with the Spring framework in mind and conform to the spring conventions.

Because the trees are based on Spring, you can only use them via the interfaces ITree<T> and ITree<K,V>.

Minimal sample code:

unit Tree;

interface

uses
  //for technical reasons you need to include both units  
  Spring.Collections.TreeIntf,  //contains the tree interfaces.
  Spring.Collections.Trees;     //contains the static tree factories.
  
var
  TreeAsSet: ITree<integer>;
  TreeAsDictionary: ITree<integer, string>;
  
implementation
initialization
  //Tree<T> factory
  TreeAsSet = Tree<integer>.RedBlackTree;
  //Tree<K,V> factory
  TreeAsDictionary = Tree<integer, string>.RedBlackTree;
  TreeAsSet.Add(1);
  TreeAsDictionary.Add(1,'test');
end.

About

Trees in Spring4D

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages