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