/jcl/source/common/JclSortedMaps.pas

https://github.com/the-Arioch/jcl · Pascal · 31806 lines · 25993 code · 1791 blank · 4022 comment · 4259 complexity · c01d72d92882d8c6d6cabf3f99cd94f1 MD5 · raw file

Large files are truncated click here to view the full file

  1. {**************************************************************************************************}
  2. { WARNING: JEDI preprocessor generated unit. Do not edit. }
  3. {**************************************************************************************************}
  4. {**************************************************************************************************}
  5. { }
  6. { Project JEDI Code Library (JCL) }
  7. { }
  8. { The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
  9. { you may not use this file except in compliance with the License. You may obtain a copy of the }
  10. { License at http://www.mozilla.org/MPL/ }
  11. { }
  12. { Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
  13. { ANY KIND, either express or implied. See the License for the specific language governing rights }
  14. { and limitations under the License. }
  15. { }
  16. { The Original Code is JclSortedMaps.pas. }
  17. { }
  18. { The Initial Developer of the Original Code is Florent Ouchet. Portions created by }
  19. { Florent Ouchet are Copyright (C) Florent Ouchet <outchy att users dott sourceforge dott net }
  20. { All rights reserved. }
  21. { }
  22. { Contributors: }
  23. { }
  24. {**************************************************************************************************}
  25. { }
  26. { The Delphi Container Library }
  27. { }
  28. {**************************************************************************************************}
  29. { }
  30. { Last modified: $Date:: $ }
  31. { Revision: $Rev:: $ }
  32. { Author: $Author:: $ }
  33. { }
  34. {**************************************************************************************************}
  35. unit JclSortedMaps;
  36. interface
  37. {$I jcl.inc}
  38. uses
  39. {$IFDEF UNITVERSIONING}
  40. JclUnitVersioning,
  41. {$ENDIF UNITVERSIONING}
  42. {$IFDEF HAS_UNITSCOPE}
  43. System.Classes,
  44. {$ELSE ~HAS_UNITSCOPE}
  45. Classes,
  46. {$ENDIF ~HAS_UNITSCOPE}
  47. JclAlgorithms,
  48. JclBase, JclSynch,
  49. JclAbstractContainers, JclContainerIntf, JclArrayLists, JclArraySets;
  50. type
  51. TJclIntfIntfSortedMapEntry = record
  52. Key: IInterface;
  53. Value: IInterface;
  54. end;
  55. TJclIntfIntfSortedMapEntryArray = array of TJclIntfIntfSortedMapEntry;
  56. TJclIntfIntfSortedMap = class(TJclIntfAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  57. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclIntfContainer,
  58. IJclIntfIntfMap, IJclIntfIntfSortedMap)
  59. protected
  60. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  61. function FreeKey(var Key: IInterface): IInterface;
  62. function FreeValue(var Value: IInterface): IInterface;
  63. function KeysCompare(const A, B: IInterface): Integer;
  64. function ValuesCompare(const A, B: IInterface): Integer;
  65. private
  66. FEntries: TJclIntfIntfSortedMapEntryArray;
  67. function BinarySearch(const Key: IInterface): Integer;
  68. protected
  69. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  70. procedure FinalizeArrayBeforeMove(var List: TJclIntfIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  71. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  72. procedure InitializeArray(var List: TJclIntfIntfSortedMapEntryArray; FromIndex, Count: SizeInt);
  73. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  74. procedure InitializeArrayAfterMove(var List: TJclIntfIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  75. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  76. procedure MoveArray(var List: TJclIntfIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  77. public
  78. constructor Create(ACapacity: Integer);
  79. destructor Destroy; override;
  80. { IJclPackable }
  81. procedure SetCapacity(Value: Integer); override;
  82. { IJclIntfIntfMap }
  83. procedure Clear;
  84. function ContainsKey(const Key: IInterface): Boolean;
  85. function ContainsValue(const Value: IInterface): Boolean;
  86. function Extract(const Key: IInterface): IInterface;
  87. function GetValue(const Key: IInterface): IInterface;
  88. function IsEmpty: Boolean;
  89. function KeyOfValue(const Value: IInterface): IInterface;
  90. function KeySet: IJclIntfSet;
  91. function MapEquals(const AMap: IJclIntfIntfMap): Boolean;
  92. procedure PutAll(const AMap: IJclIntfIntfMap);
  93. procedure PutValue(const Key: IInterface; const Value: IInterface);
  94. function Remove(const Key: IInterface): IInterface;
  95. function Size: Integer;
  96. function Values: IJclIntfCollection;
  97. { IJclIntfIntfSortedMap }
  98. function FirstKey: IInterface;
  99. function HeadMap(const ToKey: IInterface): IJclIntfIntfSortedMap;
  100. function LastKey: IInterface;
  101. function SubMap(const FromKey, ToKey: IInterface): IJclIntfIntfSortedMap;
  102. function TailMap(const FromKey: IInterface): IJclIntfIntfSortedMap;
  103. end;
  104. TJclAnsiStrIntfSortedMapEntry = record
  105. Key: AnsiString;
  106. Value: IInterface;
  107. end;
  108. TJclAnsiStrIntfSortedMapEntryArray = array of TJclAnsiStrIntfSortedMapEntry;
  109. TJclAnsiStrIntfSortedMap = class(TJclAnsiStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  110. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclAnsiStrContainer, IJclIntfContainer,
  111. IJclAnsiStrIntfMap, IJclAnsiStrIntfSortedMap)
  112. protected
  113. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  114. function FreeKey(var Key: AnsiString): AnsiString;
  115. function FreeValue(var Value: IInterface): IInterface;
  116. function KeysCompare(const A, B: AnsiString): Integer;
  117. function ValuesCompare(const A, B: IInterface): Integer;
  118. private
  119. FEntries: TJclAnsiStrIntfSortedMapEntryArray;
  120. function BinarySearch(const Key: AnsiString): Integer;
  121. protected
  122. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  123. procedure FinalizeArrayBeforeMove(var List: TJclAnsiStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  124. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  125. procedure InitializeArray(var List: TJclAnsiStrIntfSortedMapEntryArray; FromIndex, Count: SizeInt);
  126. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  127. procedure InitializeArrayAfterMove(var List: TJclAnsiStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  128. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  129. procedure MoveArray(var List: TJclAnsiStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  130. public
  131. constructor Create(ACapacity: Integer);
  132. destructor Destroy; override;
  133. { IJclPackable }
  134. procedure SetCapacity(Value: Integer); override;
  135. { IJclAnsiStrIntfMap }
  136. procedure Clear;
  137. function ContainsKey(const Key: AnsiString): Boolean;
  138. function ContainsValue(const Value: IInterface): Boolean;
  139. function Extract(const Key: AnsiString): IInterface;
  140. function GetValue(const Key: AnsiString): IInterface;
  141. function IsEmpty: Boolean;
  142. function KeyOfValue(const Value: IInterface): AnsiString;
  143. function KeySet: IJclAnsiStrSet;
  144. function MapEquals(const AMap: IJclAnsiStrIntfMap): Boolean;
  145. procedure PutAll(const AMap: IJclAnsiStrIntfMap);
  146. procedure PutValue(const Key: AnsiString; const Value: IInterface);
  147. function Remove(const Key: AnsiString): IInterface;
  148. function Size: Integer;
  149. function Values: IJclIntfCollection;
  150. { IJclAnsiStrIntfSortedMap }
  151. function FirstKey: AnsiString;
  152. function HeadMap(const ToKey: AnsiString): IJclAnsiStrIntfSortedMap;
  153. function LastKey: AnsiString;
  154. function SubMap(const FromKey, ToKey: AnsiString): IJclAnsiStrIntfSortedMap;
  155. function TailMap(const FromKey: AnsiString): IJclAnsiStrIntfSortedMap;
  156. end;
  157. TJclIntfAnsiStrSortedMapEntry = record
  158. Key: IInterface;
  159. Value: AnsiString;
  160. end;
  161. TJclIntfAnsiStrSortedMapEntryArray = array of TJclIntfAnsiStrSortedMapEntry;
  162. TJclIntfAnsiStrSortedMap = class(TJclAnsiStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  163. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclIntfContainer, IJclAnsiStrContainer,
  164. IJclIntfAnsiStrMap, IJclIntfAnsiStrSortedMap)
  165. protected
  166. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  167. function FreeKey(var Key: IInterface): IInterface;
  168. function FreeValue(var Value: AnsiString): AnsiString;
  169. function KeysCompare(const A, B: IInterface): Integer;
  170. function ValuesCompare(const A, B: AnsiString): Integer;
  171. private
  172. FEntries: TJclIntfAnsiStrSortedMapEntryArray;
  173. function BinarySearch(const Key: IInterface): Integer;
  174. protected
  175. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  176. procedure FinalizeArrayBeforeMove(var List: TJclIntfAnsiStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  177. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  178. procedure InitializeArray(var List: TJclIntfAnsiStrSortedMapEntryArray; FromIndex, Count: SizeInt);
  179. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  180. procedure InitializeArrayAfterMove(var List: TJclIntfAnsiStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  181. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  182. procedure MoveArray(var List: TJclIntfAnsiStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  183. public
  184. constructor Create(ACapacity: Integer);
  185. destructor Destroy; override;
  186. { IJclPackable }
  187. procedure SetCapacity(Value: Integer); override;
  188. { IJclIntfAnsiStrMap }
  189. procedure Clear;
  190. function ContainsKey(const Key: IInterface): Boolean;
  191. function ContainsValue(const Value: AnsiString): Boolean;
  192. function Extract(const Key: IInterface): AnsiString;
  193. function GetValue(const Key: IInterface): AnsiString;
  194. function IsEmpty: Boolean;
  195. function KeyOfValue(const Value: AnsiString): IInterface;
  196. function KeySet: IJclIntfSet;
  197. function MapEquals(const AMap: IJclIntfAnsiStrMap): Boolean;
  198. procedure PutAll(const AMap: IJclIntfAnsiStrMap);
  199. procedure PutValue(const Key: IInterface; const Value: AnsiString);
  200. function Remove(const Key: IInterface): AnsiString;
  201. function Size: Integer;
  202. function Values: IJclAnsiStrCollection;
  203. { IJclIntfAnsiStrSortedMap }
  204. function FirstKey: IInterface;
  205. function HeadMap(const ToKey: IInterface): IJclIntfAnsiStrSortedMap;
  206. function LastKey: IInterface;
  207. function SubMap(const FromKey, ToKey: IInterface): IJclIntfAnsiStrSortedMap;
  208. function TailMap(const FromKey: IInterface): IJclIntfAnsiStrSortedMap;
  209. end;
  210. TJclAnsiStrAnsiStrSortedMapEntry = record
  211. Key: AnsiString;
  212. Value: AnsiString;
  213. end;
  214. TJclAnsiStrAnsiStrSortedMapEntryArray = array of TJclAnsiStrAnsiStrSortedMapEntry;
  215. TJclAnsiStrAnsiStrSortedMap = class(TJclAnsiStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  216. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclAnsiStrContainer,
  217. IJclAnsiStrAnsiStrMap, IJclAnsiStrAnsiStrSortedMap)
  218. protected
  219. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  220. function FreeKey(var Key: AnsiString): AnsiString;
  221. function FreeValue(var Value: AnsiString): AnsiString;
  222. function KeysCompare(const A, B: AnsiString): Integer;
  223. function ValuesCompare(const A, B: AnsiString): Integer;
  224. private
  225. FEntries: TJclAnsiStrAnsiStrSortedMapEntryArray;
  226. function BinarySearch(const Key: AnsiString): Integer;
  227. protected
  228. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  229. procedure FinalizeArrayBeforeMove(var List: TJclAnsiStrAnsiStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  230. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  231. procedure InitializeArray(var List: TJclAnsiStrAnsiStrSortedMapEntryArray; FromIndex, Count: SizeInt);
  232. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  233. procedure InitializeArrayAfterMove(var List: TJclAnsiStrAnsiStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  234. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  235. procedure MoveArray(var List: TJclAnsiStrAnsiStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  236. public
  237. constructor Create(ACapacity: Integer);
  238. destructor Destroy; override;
  239. { IJclPackable }
  240. procedure SetCapacity(Value: Integer); override;
  241. { IJclAnsiStrAnsiStrMap }
  242. procedure Clear;
  243. function ContainsKey(const Key: AnsiString): Boolean;
  244. function ContainsValue(const Value: AnsiString): Boolean;
  245. function Extract(const Key: AnsiString): AnsiString;
  246. function GetValue(const Key: AnsiString): AnsiString;
  247. function IsEmpty: Boolean;
  248. function KeyOfValue(const Value: AnsiString): AnsiString;
  249. function KeySet: IJclAnsiStrSet;
  250. function MapEquals(const AMap: IJclAnsiStrAnsiStrMap): Boolean;
  251. procedure PutAll(const AMap: IJclAnsiStrAnsiStrMap);
  252. procedure PutValue(const Key: AnsiString; const Value: AnsiString);
  253. function Remove(const Key: AnsiString): AnsiString;
  254. function Size: Integer;
  255. function Values: IJclAnsiStrCollection;
  256. { IJclAnsiStrAnsiStrSortedMap }
  257. function FirstKey: AnsiString;
  258. function HeadMap(const ToKey: AnsiString): IJclAnsiStrAnsiStrSortedMap;
  259. function LastKey: AnsiString;
  260. function SubMap(const FromKey, ToKey: AnsiString): IJclAnsiStrAnsiStrSortedMap;
  261. function TailMap(const FromKey: AnsiString): IJclAnsiStrAnsiStrSortedMap;
  262. end;
  263. TJclWideStrIntfSortedMapEntry = record
  264. Key: WideString;
  265. Value: IInterface;
  266. end;
  267. TJclWideStrIntfSortedMapEntryArray = array of TJclWideStrIntfSortedMapEntry;
  268. TJclWideStrIntfSortedMap = class(TJclWideStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  269. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclWideStrContainer, IJclIntfContainer,
  270. IJclWideStrIntfMap, IJclWideStrIntfSortedMap)
  271. protected
  272. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  273. function FreeKey(var Key: WideString): WideString;
  274. function FreeValue(var Value: IInterface): IInterface;
  275. function KeysCompare(const A, B: WideString): Integer;
  276. function ValuesCompare(const A, B: IInterface): Integer;
  277. private
  278. FEntries: TJclWideStrIntfSortedMapEntryArray;
  279. function BinarySearch(const Key: WideString): Integer;
  280. protected
  281. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  282. procedure FinalizeArrayBeforeMove(var List: TJclWideStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  283. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  284. procedure InitializeArray(var List: TJclWideStrIntfSortedMapEntryArray; FromIndex, Count: SizeInt);
  285. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  286. procedure InitializeArrayAfterMove(var List: TJclWideStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  287. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  288. procedure MoveArray(var List: TJclWideStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  289. public
  290. constructor Create(ACapacity: Integer);
  291. destructor Destroy; override;
  292. { IJclPackable }
  293. procedure SetCapacity(Value: Integer); override;
  294. { IJclWideStrIntfMap }
  295. procedure Clear;
  296. function ContainsKey(const Key: WideString): Boolean;
  297. function ContainsValue(const Value: IInterface): Boolean;
  298. function Extract(const Key: WideString): IInterface;
  299. function GetValue(const Key: WideString): IInterface;
  300. function IsEmpty: Boolean;
  301. function KeyOfValue(const Value: IInterface): WideString;
  302. function KeySet: IJclWideStrSet;
  303. function MapEquals(const AMap: IJclWideStrIntfMap): Boolean;
  304. procedure PutAll(const AMap: IJclWideStrIntfMap);
  305. procedure PutValue(const Key: WideString; const Value: IInterface);
  306. function Remove(const Key: WideString): IInterface;
  307. function Size: Integer;
  308. function Values: IJclIntfCollection;
  309. { IJclWideStrIntfSortedMap }
  310. function FirstKey: WideString;
  311. function HeadMap(const ToKey: WideString): IJclWideStrIntfSortedMap;
  312. function LastKey: WideString;
  313. function SubMap(const FromKey, ToKey: WideString): IJclWideStrIntfSortedMap;
  314. function TailMap(const FromKey: WideString): IJclWideStrIntfSortedMap;
  315. end;
  316. TJclIntfWideStrSortedMapEntry = record
  317. Key: IInterface;
  318. Value: WideString;
  319. end;
  320. TJclIntfWideStrSortedMapEntryArray = array of TJclIntfWideStrSortedMapEntry;
  321. TJclIntfWideStrSortedMap = class(TJclWideStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  322. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclIntfContainer, IJclWideStrContainer,
  323. IJclIntfWideStrMap, IJclIntfWideStrSortedMap)
  324. protected
  325. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  326. function FreeKey(var Key: IInterface): IInterface;
  327. function FreeValue(var Value: WideString): WideString;
  328. function KeysCompare(const A, B: IInterface): Integer;
  329. function ValuesCompare(const A, B: WideString): Integer;
  330. private
  331. FEntries: TJclIntfWideStrSortedMapEntryArray;
  332. function BinarySearch(const Key: IInterface): Integer;
  333. protected
  334. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  335. procedure FinalizeArrayBeforeMove(var List: TJclIntfWideStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  336. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  337. procedure InitializeArray(var List: TJclIntfWideStrSortedMapEntryArray; FromIndex, Count: SizeInt);
  338. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  339. procedure InitializeArrayAfterMove(var List: TJclIntfWideStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  340. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  341. procedure MoveArray(var List: TJclIntfWideStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  342. public
  343. constructor Create(ACapacity: Integer);
  344. destructor Destroy; override;
  345. { IJclPackable }
  346. procedure SetCapacity(Value: Integer); override;
  347. { IJclIntfWideStrMap }
  348. procedure Clear;
  349. function ContainsKey(const Key: IInterface): Boolean;
  350. function ContainsValue(const Value: WideString): Boolean;
  351. function Extract(const Key: IInterface): WideString;
  352. function GetValue(const Key: IInterface): WideString;
  353. function IsEmpty: Boolean;
  354. function KeyOfValue(const Value: WideString): IInterface;
  355. function KeySet: IJclIntfSet;
  356. function MapEquals(const AMap: IJclIntfWideStrMap): Boolean;
  357. procedure PutAll(const AMap: IJclIntfWideStrMap);
  358. procedure PutValue(const Key: IInterface; const Value: WideString);
  359. function Remove(const Key: IInterface): WideString;
  360. function Size: Integer;
  361. function Values: IJclWideStrCollection;
  362. { IJclIntfWideStrSortedMap }
  363. function FirstKey: IInterface;
  364. function HeadMap(const ToKey: IInterface): IJclIntfWideStrSortedMap;
  365. function LastKey: IInterface;
  366. function SubMap(const FromKey, ToKey: IInterface): IJclIntfWideStrSortedMap;
  367. function TailMap(const FromKey: IInterface): IJclIntfWideStrSortedMap;
  368. end;
  369. TJclWideStrWideStrSortedMapEntry = record
  370. Key: WideString;
  371. Value: WideString;
  372. end;
  373. TJclWideStrWideStrSortedMapEntryArray = array of TJclWideStrWideStrSortedMapEntry;
  374. TJclWideStrWideStrSortedMap = class(TJclWideStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  375. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclWideStrContainer,
  376. IJclWideStrWideStrMap, IJclWideStrWideStrSortedMap)
  377. protected
  378. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  379. function FreeKey(var Key: WideString): WideString;
  380. function FreeValue(var Value: WideString): WideString;
  381. function KeysCompare(const A, B: WideString): Integer;
  382. function ValuesCompare(const A, B: WideString): Integer;
  383. private
  384. FEntries: TJclWideStrWideStrSortedMapEntryArray;
  385. function BinarySearch(const Key: WideString): Integer;
  386. protected
  387. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  388. procedure FinalizeArrayBeforeMove(var List: TJclWideStrWideStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  389. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  390. procedure InitializeArray(var List: TJclWideStrWideStrSortedMapEntryArray; FromIndex, Count: SizeInt);
  391. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  392. procedure InitializeArrayAfterMove(var List: TJclWideStrWideStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  393. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  394. procedure MoveArray(var List: TJclWideStrWideStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  395. public
  396. constructor Create(ACapacity: Integer);
  397. destructor Destroy; override;
  398. { IJclPackable }
  399. procedure SetCapacity(Value: Integer); override;
  400. { IJclWideStrWideStrMap }
  401. procedure Clear;
  402. function ContainsKey(const Key: WideString): Boolean;
  403. function ContainsValue(const Value: WideString): Boolean;
  404. function Extract(const Key: WideString): WideString;
  405. function GetValue(const Key: WideString): WideString;
  406. function IsEmpty: Boolean;
  407. function KeyOfValue(const Value: WideString): WideString;
  408. function KeySet: IJclWideStrSet;
  409. function MapEquals(const AMap: IJclWideStrWideStrMap): Boolean;
  410. procedure PutAll(const AMap: IJclWideStrWideStrMap);
  411. procedure PutValue(const Key: WideString; const Value: WideString);
  412. function Remove(const Key: WideString): WideString;
  413. function Size: Integer;
  414. function Values: IJclWideStrCollection;
  415. { IJclWideStrWideStrSortedMap }
  416. function FirstKey: WideString;
  417. function HeadMap(const ToKey: WideString): IJclWideStrWideStrSortedMap;
  418. function LastKey: WideString;
  419. function SubMap(const FromKey, ToKey: WideString): IJclWideStrWideStrSortedMap;
  420. function TailMap(const FromKey: WideString): IJclWideStrWideStrSortedMap;
  421. end;
  422. {$IFDEF SUPPORTS_UNICODE_STRING}
  423. TJclUnicodeStrIntfSortedMapEntry = record
  424. Key: UnicodeString;
  425. Value: IInterface;
  426. end;
  427. TJclUnicodeStrIntfSortedMapEntryArray = array of TJclUnicodeStrIntfSortedMapEntry;
  428. {$ENDIF SUPPORTS_UNICODE_STRING}
  429. {$IFDEF SUPPORTS_UNICODE_STRING}
  430. TJclUnicodeStrIntfSortedMap = class(TJclUnicodeStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  431. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclUnicodeStrContainer, IJclIntfContainer,
  432. IJclUnicodeStrIntfMap, IJclUnicodeStrIntfSortedMap)
  433. protected
  434. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  435. function FreeKey(var Key: UnicodeString): UnicodeString;
  436. function FreeValue(var Value: IInterface): IInterface;
  437. function KeysCompare(const A, B: UnicodeString): Integer;
  438. function ValuesCompare(const A, B: IInterface): Integer;
  439. private
  440. FEntries: TJclUnicodeStrIntfSortedMapEntryArray;
  441. function BinarySearch(const Key: UnicodeString): Integer;
  442. protected
  443. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  444. procedure FinalizeArrayBeforeMove(var List: TJclUnicodeStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  445. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  446. procedure InitializeArray(var List: TJclUnicodeStrIntfSortedMapEntryArray; FromIndex, Count: SizeInt);
  447. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  448. procedure InitializeArrayAfterMove(var List: TJclUnicodeStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  449. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  450. procedure MoveArray(var List: TJclUnicodeStrIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  451. public
  452. constructor Create(ACapacity: Integer);
  453. destructor Destroy; override;
  454. { IJclPackable }
  455. procedure SetCapacity(Value: Integer); override;
  456. { IJclUnicodeStrIntfMap }
  457. procedure Clear;
  458. function ContainsKey(const Key: UnicodeString): Boolean;
  459. function ContainsValue(const Value: IInterface): Boolean;
  460. function Extract(const Key: UnicodeString): IInterface;
  461. function GetValue(const Key: UnicodeString): IInterface;
  462. function IsEmpty: Boolean;
  463. function KeyOfValue(const Value: IInterface): UnicodeString;
  464. function KeySet: IJclUnicodeStrSet;
  465. function MapEquals(const AMap: IJclUnicodeStrIntfMap): Boolean;
  466. procedure PutAll(const AMap: IJclUnicodeStrIntfMap);
  467. procedure PutValue(const Key: UnicodeString; const Value: IInterface);
  468. function Remove(const Key: UnicodeString): IInterface;
  469. function Size: Integer;
  470. function Values: IJclIntfCollection;
  471. { IJclUnicodeStrIntfSortedMap }
  472. function FirstKey: UnicodeString;
  473. function HeadMap(const ToKey: UnicodeString): IJclUnicodeStrIntfSortedMap;
  474. function LastKey: UnicodeString;
  475. function SubMap(const FromKey, ToKey: UnicodeString): IJclUnicodeStrIntfSortedMap;
  476. function TailMap(const FromKey: UnicodeString): IJclUnicodeStrIntfSortedMap;
  477. end;
  478. {$ENDIF SUPPORTS_UNICODE_STRING}
  479. {$IFDEF SUPPORTS_UNICODE_STRING}
  480. TJclIntfUnicodeStrSortedMapEntry = record
  481. Key: IInterface;
  482. Value: UnicodeString;
  483. end;
  484. TJclIntfUnicodeStrSortedMapEntryArray = array of TJclIntfUnicodeStrSortedMapEntry;
  485. {$ENDIF SUPPORTS_UNICODE_STRING}
  486. {$IFDEF SUPPORTS_UNICODE_STRING}
  487. TJclIntfUnicodeStrSortedMap = class(TJclUnicodeStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  488. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclIntfContainer, IJclUnicodeStrContainer,
  489. IJclIntfUnicodeStrMap, IJclIntfUnicodeStrSortedMap)
  490. protected
  491. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  492. function FreeKey(var Key: IInterface): IInterface;
  493. function FreeValue(var Value: UnicodeString): UnicodeString;
  494. function KeysCompare(const A, B: IInterface): Integer;
  495. function ValuesCompare(const A, B: UnicodeString): Integer;
  496. private
  497. FEntries: TJclIntfUnicodeStrSortedMapEntryArray;
  498. function BinarySearch(const Key: IInterface): Integer;
  499. protected
  500. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  501. procedure FinalizeArrayBeforeMove(var List: TJclIntfUnicodeStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  502. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  503. procedure InitializeArray(var List: TJclIntfUnicodeStrSortedMapEntryArray; FromIndex, Count: SizeInt);
  504. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  505. procedure InitializeArrayAfterMove(var List: TJclIntfUnicodeStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  506. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  507. procedure MoveArray(var List: TJclIntfUnicodeStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  508. public
  509. constructor Create(ACapacity: Integer);
  510. destructor Destroy; override;
  511. { IJclPackable }
  512. procedure SetCapacity(Value: Integer); override;
  513. { IJclIntfUnicodeStrMap }
  514. procedure Clear;
  515. function ContainsKey(const Key: IInterface): Boolean;
  516. function ContainsValue(const Value: UnicodeString): Boolean;
  517. function Extract(const Key: IInterface): UnicodeString;
  518. function GetValue(const Key: IInterface): UnicodeString;
  519. function IsEmpty: Boolean;
  520. function KeyOfValue(const Value: UnicodeString): IInterface;
  521. function KeySet: IJclIntfSet;
  522. function MapEquals(const AMap: IJclIntfUnicodeStrMap): Boolean;
  523. procedure PutAll(const AMap: IJclIntfUnicodeStrMap);
  524. procedure PutValue(const Key: IInterface; const Value: UnicodeString);
  525. function Remove(const Key: IInterface): UnicodeString;
  526. function Size: Integer;
  527. function Values: IJclUnicodeStrCollection;
  528. { IJclIntfUnicodeStrSortedMap }
  529. function FirstKey: IInterface;
  530. function HeadMap(const ToKey: IInterface): IJclIntfUnicodeStrSortedMap;
  531. function LastKey: IInterface;
  532. function SubMap(const FromKey, ToKey: IInterface): IJclIntfUnicodeStrSortedMap;
  533. function TailMap(const FromKey: IInterface): IJclIntfUnicodeStrSortedMap;
  534. end;
  535. {$ENDIF SUPPORTS_UNICODE_STRING}
  536. {$IFDEF SUPPORTS_UNICODE_STRING}
  537. TJclUnicodeStrUnicodeStrSortedMapEntry = record
  538. Key: UnicodeString;
  539. Value: UnicodeString;
  540. end;
  541. TJclUnicodeStrUnicodeStrSortedMapEntryArray = array of TJclUnicodeStrUnicodeStrSortedMapEntry;
  542. {$ENDIF SUPPORTS_UNICODE_STRING}
  543. {$IFDEF SUPPORTS_UNICODE_STRING}
  544. TJclUnicodeStrUnicodeStrSortedMap = class(TJclUnicodeStrAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  545. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclStrBaseContainer, IJclUnicodeStrContainer,
  546. IJclUnicodeStrUnicodeStrMap, IJclUnicodeStrUnicodeStrSortedMap)
  547. protected
  548. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  549. function FreeKey(var Key: UnicodeString): UnicodeString;
  550. function FreeValue(var Value: UnicodeString): UnicodeString;
  551. function KeysCompare(const A, B: UnicodeString): Integer;
  552. function ValuesCompare(const A, B: UnicodeString): Integer;
  553. private
  554. FEntries: TJclUnicodeStrUnicodeStrSortedMapEntryArray;
  555. function BinarySearch(const Key: UnicodeString): Integer;
  556. protected
  557. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  558. procedure FinalizeArrayBeforeMove(var List: TJclUnicodeStrUnicodeStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  559. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  560. procedure InitializeArray(var List: TJclUnicodeStrUnicodeStrSortedMapEntryArray; FromIndex, Count: SizeInt);
  561. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  562. procedure InitializeArrayAfterMove(var List: TJclUnicodeStrUnicodeStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  563. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  564. procedure MoveArray(var List: TJclUnicodeStrUnicodeStrSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  565. public
  566. constructor Create(ACapacity: Integer);
  567. destructor Destroy; override;
  568. { IJclPackable }
  569. procedure SetCapacity(Value: Integer); override;
  570. { IJclUnicodeStrUnicodeStrMap }
  571. procedure Clear;
  572. function ContainsKey(const Key: UnicodeString): Boolean;
  573. function ContainsValue(const Value: UnicodeString): Boolean;
  574. function Extract(const Key: UnicodeString): UnicodeString;
  575. function GetValue(const Key: UnicodeString): UnicodeString;
  576. function IsEmpty: Boolean;
  577. function KeyOfValue(const Value: UnicodeString): UnicodeString;
  578. function KeySet: IJclUnicodeStrSet;
  579. function MapEquals(const AMap: IJclUnicodeStrUnicodeStrMap): Boolean;
  580. procedure PutAll(const AMap: IJclUnicodeStrUnicodeStrMap);
  581. procedure PutValue(const Key: UnicodeString; const Value: UnicodeString);
  582. function Remove(const Key: UnicodeString): UnicodeString;
  583. function Size: Integer;
  584. function Values: IJclUnicodeStrCollection;
  585. { IJclUnicodeStrUnicodeStrSortedMap }
  586. function FirstKey: UnicodeString;
  587. function HeadMap(const ToKey: UnicodeString): IJclUnicodeStrUnicodeStrSortedMap;
  588. function LastKey: UnicodeString;
  589. function SubMap(const FromKey, ToKey: UnicodeString): IJclUnicodeStrUnicodeStrSortedMap;
  590. function TailMap(const FromKey: UnicodeString): IJclUnicodeStrUnicodeStrSortedMap;
  591. end;
  592. {$ENDIF SUPPORTS_UNICODE_STRING}
  593. {$IFDEF CONTAINER_ANSISTR}
  594. TJclStrIntfSortedMapEntry = TJclAnsiStrIntfSortedMapEntry;
  595. {$ENDIF CONTAINER_ANSISTR}
  596. {$IFDEF CONTAINER_WIDESTR}
  597. TJclStrIntfSortedMapEntry = TJclWideStrIntfSortedMapEntry;
  598. {$ENDIF CONTAINER_WIDESTR}
  599. {$IFDEF CONTAINER_UNICODESTR}
  600. TJclStrIntfSortedMapEntry = TJclUnicodeStrIntfSortedMapEntry;
  601. {$ENDIF CONTAINER_UNICODESTR}
  602. {$IFDEF CONTAINER_ANSISTR}
  603. TJclStrIntfSortedMap = TJclAnsiStrIntfSortedMap;
  604. {$ENDIF CONTAINER_ANSISTR}
  605. {$IFDEF CONTAINER_WIDESTR}
  606. TJclStrIntfSortedMap = TJclWideStrIntfSortedMap;
  607. {$ENDIF CONTAINER_WIDESTR}
  608. {$IFDEF CONTAINER_UNICODESTR}
  609. TJclStrIntfSortedMap = TJclUnicodeStrIntfSortedMap;
  610. {$ENDIF CONTAINER_UNICODESTR}
  611. {$IFDEF CONTAINER_ANSISTR}
  612. TJclIntfStrSortedMapEntry = TJclIntfAnsiStrSortedMapEntry;
  613. {$ENDIF CONTAINER_ANSISTR}
  614. {$IFDEF CONTAINER_WIDESTR}
  615. TJclIntfStrSortedMapEntry = TJclIntfWideStrSortedMapEntry;
  616. {$ENDIF CONTAINER_WIDESTR}
  617. {$IFDEF CONTAINER_UNICODESTR}
  618. TJclIntfStrSortedMapEntry = TJclIntfUnicodeStrSortedMapEntry;
  619. {$ENDIF CONTAINER_UNICODESTR}
  620. {$IFDEF CONTAINER_ANSISTR}
  621. TJclIntfStrSortedMap = TJclIntfAnsiStrSortedMap;
  622. {$ENDIF CONTAINER_ANSISTR}
  623. {$IFDEF CONTAINER_WIDESTR}
  624. TJclIntfStrSortedMap = TJclIntfWideStrSortedMap;
  625. {$ENDIF CONTAINER_WIDESTR}
  626. {$IFDEF CONTAINER_UNICODESTR}
  627. TJclIntfStrSortedMap = TJclIntfUnicodeStrSortedMap;
  628. {$ENDIF CONTAINER_UNICODESTR}
  629. {$IFDEF CONTAINER_ANSISTR}
  630. TJclStrStrSortedMapEntry = TJclAnsiStrAnsiStrSortedMapEntry;
  631. {$ENDIF CONTAINER_ANSISTR}
  632. {$IFDEF CONTAINER_WIDESTR}
  633. TJclStrStrSortedMapEntry = TJclWideStrWideStrSortedMapEntry;
  634. {$ENDIF CONTAINER_WIDESTR}
  635. {$IFDEF CONTAINER_UNICODESTR}
  636. TJclStrStrSortedMapEntry = TJclUnicodeStrUnicodeStrSortedMapEntry;
  637. {$ENDIF CONTAINER_UNICODESTR}
  638. {$IFDEF CONTAINER_ANSISTR}
  639. TJclStrStrSortedMap = TJclAnsiStrAnsiStrSortedMap;
  640. {$ENDIF CONTAINER_ANSISTR}
  641. {$IFDEF CONTAINER_WIDESTR}
  642. TJclStrStrSortedMap = TJclWideStrWideStrSortedMap;
  643. {$ENDIF CONTAINER_WIDESTR}
  644. {$IFDEF CONTAINER_UNICODESTR}
  645. TJclStrStrSortedMap = TJclUnicodeStrUnicodeStrSortedMap;
  646. {$ENDIF CONTAINER_UNICODESTR}
  647. TJclSingleIntfSortedMapEntry = record
  648. Key: Single;
  649. Value: IInterface;
  650. end;
  651. TJclSingleIntfSortedMapEntryArray = array of TJclSingleIntfSortedMapEntry;
  652. TJclSingleIntfSortedMap = class(TJclSingleAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  653. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclSingleContainer, IJclIntfContainer,
  654. IJclSingleIntfMap, IJclSingleIntfSortedMap)
  655. protected
  656. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  657. function FreeKey(var Key: Single): Single;
  658. function FreeValue(var Value: IInterface): IInterface;
  659. function KeysCompare(const A, B: Single): Integer;
  660. function ValuesCompare(const A, B: IInterface): Integer;
  661. private
  662. FEntries: TJclSingleIntfSortedMapEntryArray;
  663. function BinarySearch(const Key: Single): Integer;
  664. protected
  665. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  666. procedure FinalizeArrayBeforeMove(var List: TJclSingleIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  667. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  668. procedure InitializeArray(var List: TJclSingleIntfSortedMapEntryArray; FromIndex, Count: SizeInt);
  669. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  670. procedure InitializeArrayAfterMove(var List: TJclSingleIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  671. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  672. procedure MoveArray(var List: TJclSingleIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  673. public
  674. constructor Create(ACapacity: Integer);
  675. destructor Destroy; override;
  676. { IJclPackable }
  677. procedure SetCapacity(Value: Integer); override;
  678. { IJclSingleIntfMap }
  679. procedure Clear;
  680. function ContainsKey(const Key: Single): Boolean;
  681. function ContainsValue(const Value: IInterface): Boolean;
  682. function Extract(const Key: Single): IInterface;
  683. function GetValue(const Key: Single): IInterface;
  684. function IsEmpty: Boolean;
  685. function KeyOfValue(const Value: IInterface): Single;
  686. function KeySet: IJclSingleSet;
  687. function MapEquals(const AMap: IJclSingleIntfMap): Boolean;
  688. procedure PutAll(const AMap: IJclSingleIntfMap);
  689. procedure PutValue(const Key: Single; const Value: IInterface);
  690. function Remove(const Key: Single): IInterface;
  691. function Size: Integer;
  692. function Values: IJclIntfCollection;
  693. { IJclSingleIntfSortedMap }
  694. function FirstKey: Single;
  695. function HeadMap(const ToKey: Single): IJclSingleIntfSortedMap;
  696. function LastKey: Single;
  697. function SubMap(const FromKey, ToKey: Single): IJclSingleIntfSortedMap;
  698. function TailMap(const FromKey: Single): IJclSingleIntfSortedMap;
  699. end;
  700. TJclIntfSingleSortedMapEntry = record
  701. Key: IInterface;
  702. Value: Single;
  703. end;
  704. TJclIntfSingleSortedMapEntryArray = array of TJclIntfSingleSortedMapEntry;
  705. TJclIntfSingleSortedMap = class(TJclSingleAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  706. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclIntfContainer, IJclSingleContainer,
  707. IJclIntfSingleMap, IJclIntfSingleSortedMap)
  708. protected
  709. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  710. function FreeKey(var Key: IInterface): IInterface;
  711. function FreeValue(var Value: Single): Single;
  712. function KeysCompare(const A, B: IInterface): Integer;
  713. function ValuesCompare(const A, B: Single): Integer;
  714. private
  715. FEntries: TJclIntfSingleSortedMapEntryArray;
  716. function BinarySearch(const Key: IInterface): Integer;
  717. protected
  718. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  719. procedure FinalizeArrayBeforeMove(var List: TJclIntfSingleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  720. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  721. procedure InitializeArray(var List: TJclIntfSingleSortedMapEntryArray; FromIndex, Count: SizeInt);
  722. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  723. procedure InitializeArrayAfterMove(var List: TJclIntfSingleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  724. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  725. procedure MoveArray(var List: TJclIntfSingleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  726. public
  727. constructor Create(ACapacity: Integer);
  728. destructor Destroy; override;
  729. { IJclPackable }
  730. procedure SetCapacity(Value: Integer); override;
  731. { IJclIntfSingleMap }
  732. procedure Clear;
  733. function ContainsKey(const Key: IInterface): Boolean;
  734. function ContainsValue(const Value: Single): Boolean;
  735. function Extract(const Key: IInterface): Single;
  736. function GetValue(const Key: IInterface): Single;
  737. function IsEmpty: Boolean;
  738. function KeyOfValue(const Value: Single): IInterface;
  739. function KeySet: IJclIntfSet;
  740. function MapEquals(const AMap: IJclIntfSingleMap): Boolean;
  741. procedure PutAll(const AMap: IJclIntfSingleMap);
  742. procedure PutValue(const Key: IInterface; const Value: Single);
  743. function Remove(const Key: IInterface): Single;
  744. function Size: Integer;
  745. function Values: IJclSingleCollection;
  746. { IJclIntfSingleSortedMap }
  747. function FirstKey: IInterface;
  748. function HeadMap(const ToKey: IInterface): IJclIntfSingleSortedMap;
  749. function LastKey: IInterface;
  750. function SubMap(const FromKey, ToKey: IInterface): IJclIntfSingleSortedMap;
  751. function TailMap(const FromKey: IInterface): IJclIntfSingleSortedMap;
  752. end;
  753. TJclSingleSingleSortedMapEntry = record
  754. Key: Single;
  755. Value: Single;
  756. end;
  757. TJclSingleSingleSortedMapEntryArray = array of TJclSingleSingleSortedMapEntry;
  758. TJclSingleSingleSortedMap = class(TJclSingleAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  759. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclSingleContainer,
  760. IJclSingleSingleMap, IJclSingleSingleSortedMap)
  761. protected
  762. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  763. function FreeKey(var Key: Single): Single;
  764. function FreeValue(var Value: Single): Single;
  765. function KeysCompare(const A, B: Single): Integer;
  766. function ValuesCompare(const A, B: Single): Integer;
  767. private
  768. FEntries: TJclSingleSingleSortedMapEntryArray;
  769. function BinarySearch(const Key: Single): Integer;
  770. protected
  771. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  772. procedure InitializeArrayAfterMove(var List: TJclSingleSingleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  773. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  774. procedure MoveArray(var List: TJclSingleSingleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  775. public
  776. constructor Create(ACapacity: Integer);
  777. destructor Destroy; override;
  778. { IJclPackable }
  779. procedure SetCapacity(Value: Integer); override;
  780. { IJclSingleSingleMap }
  781. procedure Clear;
  782. function ContainsKey(const Key: Single): Boolean;
  783. function ContainsValue(const Value: Single): Boolean;
  784. function Extract(const Key: Single): Single;
  785. function GetValue(const Key: Single): Single;
  786. function IsEmpty: Boolean;
  787. function KeyOfValue(const Value: Single): Single;
  788. function KeySet: IJclSingleSet;
  789. function MapEquals(const AMap: IJclSingleSingleMap): Boolean;
  790. procedure PutAll(const AMap: IJclSingleSingleMap);
  791. procedure PutValue(const Key: Single; const Value: Single);
  792. function Remove(const Key: Single): Single;
  793. function Size: Integer;
  794. function Values: IJclSingleCollection;
  795. { IJclSingleSingleSortedMap }
  796. function FirstKey: Single;
  797. function HeadMap(const ToKey: Single): IJclSingleSingleSortedMap;
  798. function LastKey: Single;
  799. function SubMap(const FromKey, ToKey: Single): IJclSingleSingleSortedMap;
  800. function TailMap(const FromKey: Single): IJclSingleSingleSortedMap;
  801. end;
  802. TJclDoubleIntfSortedMapEntry = record
  803. Key: Double;
  804. Value: IInterface;
  805. end;
  806. TJclDoubleIntfSortedMapEntryArray = array of TJclDoubleIntfSortedMapEntry;
  807. TJclDoubleIntfSortedMap = class(TJclDoubleAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  808. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclDoubleContainer, IJclIntfContainer,
  809. IJclDoubleIntfMap, IJclDoubleIntfSortedMap)
  810. protected
  811. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  812. function FreeKey(var Key: Double): Double;
  813. function FreeValue(var Value: IInterface): IInterface;
  814. function KeysCompare(const A, B: Double): Integer;
  815. function ValuesCompare(const A, B: IInterface): Integer;
  816. private
  817. FEntries: TJclDoubleIntfSortedMapEntryArray;
  818. function BinarySearch(const Key: Double): Integer;
  819. protected
  820. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  821. procedure FinalizeArrayBeforeMove(var List: TJclDoubleIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  822. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  823. procedure InitializeArray(var List: TJclDoubleIntfSortedMapEntryArray; FromIndex, Count: SizeInt);
  824. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  825. procedure InitializeArrayAfterMove(var List: TJclDoubleIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  826. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  827. procedure MoveArray(var List: TJclDoubleIntfSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  828. public
  829. constructor Create(ACapacity: Integer);
  830. destructor Destroy; override;
  831. { IJclPackable }
  832. procedure SetCapacity(Value: Integer); override;
  833. { IJclDoubleIntfMap }
  834. procedure Clear;
  835. function ContainsKey(const Key: Double): Boolean;
  836. function ContainsValue(const Value: IInterface): Boolean;
  837. function Extract(const Key: Double): IInterface;
  838. function GetValue(const Key: Double): IInterface;
  839. function IsEmpty: Boolean;
  840. function KeyOfValue(const Value: IInterface): Double;
  841. function KeySet: IJclDoubleSet;
  842. function MapEquals(const AMap: IJclDoubleIntfMap): Boolean;
  843. procedure PutAll(const AMap: IJclDoubleIntfMap);
  844. procedure PutValue(const Key: Double; const Value: IInterface);
  845. function Remove(const Key: Double): IInterface;
  846. function Size: Integer;
  847. function Values: IJclIntfCollection;
  848. { IJclDoubleIntfSortedMap }
  849. function FirstKey: Double;
  850. function HeadMap(const ToKey: Double): IJclDoubleIntfSortedMap;
  851. function LastKey: Double;
  852. function SubMap(const FromKey, ToKey: Double): IJclDoubleIntfSortedMap;
  853. function TailMap(const FromKey: Double): IJclDoubleIntfSortedMap;
  854. end;
  855. TJclIntfDoubleSortedMapEntry = record
  856. Key: IInterface;
  857. Value: Double;
  858. end;
  859. TJclIntfDoubleSortedMapEntryArray = array of TJclIntfDoubleSortedMapEntry;
  860. TJclIntfDoubleSortedMap = class(TJclDoubleAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  861. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclIntfContainer, IJclDoubleContainer,
  862. IJclIntfDoubleMap, IJclIntfDoubleSortedMap)
  863. protected
  864. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  865. function FreeKey(var Key: IInterface): IInterface;
  866. function FreeValue(var Value: Double): Double;
  867. function KeysCompare(const A, B: IInterface): Integer;
  868. function ValuesCompare(const A, B: Double): Integer;
  869. private
  870. FEntries: TJclIntfDoubleSortedMapEntryArray;
  871. function BinarySearch(const Key: IInterface): Integer;
  872. protected
  873. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  874. procedure FinalizeArrayBeforeMove(var List: TJclIntfDoubleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  875. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  876. procedure InitializeArray(var List: TJclIntfDoubleSortedMapEntryArray; FromIndex, Count: SizeInt);
  877. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  878. procedure InitializeArrayAfterMove(var List: TJclIntfDoubleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  879. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  880. procedure MoveArray(var List: TJclIntfDoubleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  881. public
  882. constructor Create(ACapacity: Integer);
  883. destructor Destroy; override;
  884. { IJclPackable }
  885. procedure SetCapacity(Value: Integer); override;
  886. { IJclIntfDoubleMap }
  887. procedure Clear;
  888. function ContainsKey(const Key: IInterface): Boolean;
  889. function ContainsValue(const Value: Double): Boolean;
  890. function Extract(const Key: IInterface): Double;
  891. function GetValue(const Key: IInterface): Double;
  892. function IsEmpty: Boolean;
  893. function KeyOfValue(const Value: Double): IInterface;
  894. function KeySet: IJclIntfSet;
  895. function MapEquals(const AMap: IJclIntfDoubleMap): Boolean;
  896. procedure PutAll(const AMap: IJclIntfDoubleMap);
  897. procedure PutValue(const Key: IInterface; const Value: Double);
  898. function Remove(const Key: IInterface): Double;
  899. function Size: Integer;
  900. function Values: IJclDoubleCollection;
  901. { IJclIntfDoubleSortedMap }
  902. function FirstKey: IInterface;
  903. function HeadMap(const ToKey: IInterface): IJclIntfDoubleSortedMap;
  904. function LastKey: IInterface;
  905. function SubMap(const FromKey, ToKey: IInterface): IJclIntfDoubleSortedMap;
  906. function TailMap(const FromKey: IInterface): IJclIntfDoubleSortedMap;
  907. end;
  908. TJclDoubleDoubleSortedMapEntry = record
  909. Key: Double;
  910. Value: Double;
  911. end;
  912. TJclDoubleDoubleSortedMapEntryArray = array of TJclDoubleDoubleSortedMapEntry;
  913. TJclDoubleDoubleSortedMap = class(TJclDoubleAbstractContainer, {$IFDEF THREADSAFE} IJclLockable, {$ENDIF THREADSAFE}
  914. IJclIntfCloneable, IJclCloneable, IJclGrowable, IJclPackable, IJclBaseContainer, IJclDoubleContainer,
  915. IJclDoubleDoubleMap, IJclDoubleDoubleSortedMap)
  916. protected
  917. function CreateEmptyContainer: TJclAbstractContainerBase; override;
  918. function FreeKey(var Key: Double): Double;
  919. function FreeValue(var Value: Double): Double;
  920. function KeysCompare(const A, B: Double): Integer;
  921. function ValuesCompare(const A, B: Double): Integer;
  922. private
  923. FEntries: TJclDoubleDoubleSortedMapEntryArray;
  924. function BinarySearch(const Key: Double): Integer;
  925. protected
  926. procedure AssignDataTo(Dest: TJclAbstractContainerBase); override;
  927. procedure InitializeArrayAfterMove(var List: TJclDoubleDoubleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  928. {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF}
  929. procedure MoveArray(var List: TJclDoubleDoubleSortedMapEntryArray; FromIndex, ToIndex, Count: SizeInt);
  930. public
  931. constructor Create(ACapacity: Integer);
  932. destructor Destroy; override;
  933. { IJclPackable }
  934. procedure SetCapacity(Value: Integer); override;
  935. { IJclDoubleDoubleMap }
  936. procedure Clear;
  937. function ContainsKey(const Key: Double): Boolean;
  938. function ContainsValue(const Value