PageRenderTime 26ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/jcl/source/prototypes/containers/JclTrees.int

https://github.com/the-Arioch/jcl
Unknown | 133 lines | 131 code | 2 blank | 0 comment | 0 complexity | ad945bad55d2d56cf5d5edb6157cac58 MD5 | raw file
Possible License(s): BSD-3-Clause
  1(*$JPPDEFINEMACRO JCLTREETYPESINT(NODETYPENAME, EQUALITYCOMPARERINTERFACENAME, CONSTKEYWORD, PARAMETERNAME, TYPENAME)
  2NODETYPENAME = class
  3public
  4  Value: TYPENAME;
  5  {$IFDEF BCB}
  6  Children: TDynObjectArray;
  7  {$ELSE ~BCB}
  8  Children: array of NODETYPENAME;
  9  {$ENDIF ~BCB}
 10  ChildrenCount: Integer;
 11  Parent: NODETYPENAME;
 12  function IndexOfChild(AChild: NODETYPENAME): Integer;
 13  function IndexOfValue(CONSTKEYWORDPARAMETERNAME: TYPENAME; const AEqualityComparer: EQUALITYCOMPARERINTERFACENAME): Integer;
 14end;*)
 15(*$JPPDEFINEMACRO JCLTREEINT(NODETYPENAME, SELFCLASSNAME, ANCESTORCLASSNAME, BASECONTAINERINTERFACENAME, FLATCONTAINERINTERFACENAME,
 16  EQUALITYCOMPARERINTERFACENAME, COLLECTIONINTERFACENAME, TREEINTERFACENAME, STDITRINTERFACENAME, TREEITRINTERFACENAME,
 17  INTERFACEADDITIONAL, SECTIONADDITIONAL, COLLECTIONFLAGS, OWNERSHIPDECLARATION,
 18  CONSTKEYWORD, PARAMETERNAME, TYPENAME, DEFAULTVALUE)
 19SELFCLASSNAME = class(ANCESTORCLASSNAME, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
 20  IJclIntfCloneable, IJclCloneable, IJclPackable, IJclGrowable, IJclBaseContainer,
 21  BASECONTAINERINTERFACENAME, FLATCONTAINERINTERFACENAME, EQUALITYCOMPARERINTERFACENAME,INTERFACEADDITIONAL
 22  COLLECTIONINTERFACENAME, TREEINTERFACENAME)SECTIONADDITIONAL
 23private
 24  FRoot: NODETYPENAME;
 25  FTraverseOrder: TJclTraverseOrder;
 26protected
 27  procedure ExtractNode(var ANode: NODETYPENAME);
 28  procedure RemoveNode(var ANode: NODETYPENAME);
 29  function CloneNode(Node, Parent: NODETYPENAME): NODETYPENAME;
 30  function NodeContains(ANode: NODETYPENAME; CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;
 31  procedure PackNode(ANode: NODETYPENAME);
 32  procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
 33  procedure AssignPropertiesTo(Dest: TJclAbstractContainerBase); override;
 34public
 35  constructor Create(OWNERSHIPDECLARATION);
 36  destructor Destroy; override;
 37  { IJclPackable }
 38  procedure Pack; override;
 39  procedure SetCapacity(Value: Integer); override;
 40  { COLLECTIONINTERFACENAME }
 41  function Add(CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;COLLECTIONFLAGS
 42  function AddAll(const ACollection: COLLECTIONINTERFACENAME): Boolean;COLLECTIONFLAGS
 43  procedure Clear;COLLECTIONFLAGS
 44  function CollectionEquals(const ACollection: COLLECTIONINTERFACENAME): Boolean;COLLECTIONFLAGS
 45  function Contains(CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;COLLECTIONFLAGS
 46  function ContainsAll(const ACollection: COLLECTIONINTERFACENAME): Boolean;COLLECTIONFLAGS
 47  function Extract(CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;COLLECTIONFLAGS
 48  function ExtractAll(const ACollection: COLLECTIONINTERFACENAME): Boolean;COLLECTIONFLAGS
 49  function First: STDITRINTERFACENAME;COLLECTIONFLAGS
 50  function IsEmpty: Boolean;COLLECTIONFLAGS
 51  function Last: STDITRINTERFACENAME;COLLECTIONFLAGS
 52  function Remove(CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;COLLECTIONFLAGS
 53  function RemoveAll(const ACollection: COLLECTIONINTERFACENAME): Boolean;COLLECTIONFLAGS
 54  function RetainAll(const ACollection: COLLECTIONINTERFACENAME): Boolean;COLLECTIONFLAGS
 55  function Size: Integer;COLLECTIONFLAGS
 56  {$IFDEF SUPPORTS_FOR_IN}
 57  function GetEnumerator: STDITRINTERFACENAME;COLLECTIONFLAGS
 58  {$ENDIF SUPPORTS_FOR_IN}
 59  { TREEINTERFACENAME }
 60  function GetRoot: TREEITRINTERFACENAME;
 61  function GetTraverseOrder: TJclTraverseOrder;
 62  procedure SetTraverseOrder(Value: TJclTraverseOrder);
 63  property Root: TREEITRINTERFACENAME read GetRoot;
 64  property TraverseOrder: TJclTraverseOrder read GetTraverseOrder write SetTraverseOrder;
 65end;*)
 66(*$JPPDEFINEMACRO JCLTREEITRINT(BASEITRCLASSNAME, PREORDERITRCLASSNAME, POSTORDERITRCLASSNAME, NODETYPENAME, TREECLASSNAME,
 67  STDITRINTERFACENAME, TREEITRINTERFACENAME, EQUALITYCOMPARERINTERFACENAME,
 68  CONSTKEYWORD, PARAMETERNAME, TYPENAME, DEFAULTVALUE, GETTERFUNCTIONNAME, SETTERPROCEDURENAME)
 69BASEITRCLASSNAME = class(TJclAbstractIterator, STDITRINTERFACENAME, TREEITRINTERFACENAME)
 70protected
 71  FCursor: NODETYPENAME;
 72  FStart: TItrStart;
 73  FOwnTree: TREECLASSNAME;
 74  FEqualityComparer: EQUALITYCOMPARERINTERFACENAME; // keep a reference  of tree interface
 75  procedure AssignPropertiesTo(Dest: TJclAbstractIterator); override;
 76  function GetNextCursor: NODETYPENAME; virtual; abstract;
 77  // return next node on the same level
 78  function GetNextSibling: NODETYPENAME; virtual; abstract;
 79  function GetPreviousCursor: NODETYPENAME; virtual; abstract;
 80public
 81  constructor Create(OwnTree: TREECLASSNAME; ACursor: NODETYPENAME; AValid: Boolean; AStart: TItrStart);
 82  { STDITRINTERFACENAME }
 83  function Add(CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;
 84  procedure Extract;
 85  function GETTERFUNCTIONNAME: TYPENAME;
 86  function HasNext: Boolean;
 87  function HasPrevious: Boolean;
 88  function Insert(CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;
 89  function IteratorEquals(const AIterator: STDITRINTERFACENAME): Boolean;
 90  function Next: TYPENAME;
 91  function NextIndex: Integer;
 92  function Previous: TYPENAME;
 93  function PreviousIndex: Integer;
 94  procedure Remove;
 95  procedure Reset;
 96  procedure SETTERPROCEDURENAME(CONSTKEYWORDPARAMETERNAME: TYPENAME);
 97  {$IFDEF SUPPORTS_FOR_IN}
 98  function MoveNext: Boolean;
 99  property Current: TYPENAME read GETTERFUNCTIONNAME;
100  {$ENDIF SUPPORTS_FOR_IN}
101  { TREEITRINTERFACENAME }
102  function AddChild(CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;
103  function ChildrenCount: Integer;
104  procedure DeleteChild(Index: Integer);
105  procedure DeleteChildren;
106  procedure ExtractChild(Index: Integer);
107  procedure ExtractChildren;
108  function GetChild(Index: Integer): TYPENAME;
109  function HasChild(Index: Integer): Boolean;
110  function HasParent: Boolean;
111  function IndexOfChild(CONSTKEYWORDPARAMETERNAME: TYPENAME): Integer;
112  function InsertChild(Index: Integer; CONSTKEYWORDPARAMETERNAME: TYPENAME): Boolean;
113  function Parent: TYPENAME;
114  procedure SetChild(Index: Integer; CONSTKEYWORDPARAMETERNAME: TYPENAME);
115end;
116
117PREORDERITRCLASSNAME = class(BASEITRCLASSNAME, STDITRINTERFACENAME, TREEITRINTERFACENAME, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
118  IJclIntfCloneable, IJclCloneable)
119protected
120  function CreateEmptyIterator: TJclAbstractIterator; override;
121  function GetNextCursor: NODETYPENAME; override;
122  function GetNextSibling: NODETYPENAME; override;
123  function GetPreviousCursor: NODETYPENAME; override;
124end;
125
126POSTORDERITRCLASSNAME = class(BASEITRCLASSNAME, STDITRINTERFACENAME, TREEITRINTERFACENAME, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
127  IJclIntfCloneable, IJclCloneable)
128protected
129  function CreateEmptyIterator: TJclAbstractIterator; override;
130  function GetNextCursor: NODETYPENAME; override;
131  function GetNextSibling: NODETYPENAME; override;
132  function GetPreviousCursor: NODETYPENAME; override;
133end;*)