lazarus/components/sparta/generics/examples/THashMapCaseInsensitive/THashMapCaseInsensitive.lpr
hnb d53cfa9c28 Merged revision(s) 51414, 51448-51450, 51468, 51473, 51477, 51480, 51483, 51486, 51511, 51543-51544, 51638, 52714, 52725-52727 from branches/free-sparta:
sparta: initial commit of "compilable" new sparta package - smart form editor. !NOTE: not for daily usage.
........
sparta: Initial conception for package for MDI: sparta_MDI. Base for sparta_DockedFormEditor package.
........
sparta: Generics.Collections library ( sync with https://github.com/dathox/generics.collections SHA fda586932bd80ef58c08f8ebf5a24316ca4ccca5)
........
sparta: smart form editor adjustment for new sparta_MDI
........
sparta: new class "TFormImpl" for MDI solution (created from TDesignedFormImpl). 
........
sparta: 
-MDI form container "TFormContainer"
-New IResizeFrame interface to handle MDI form moving
-New frame TfrFormBackgroundForMDI
........
sparta: sparta_MDI package modifications:
-new class TMultiplyResizer to menage MDI desktop
-more generic resizer: TAbstractResizer. Base for IDE resizer and TMultiplyResizer
-more advanced IResizeFrame interface


........
sparta: 
-DockedFormEditor adjustment for latest changes in mdi package
-small changes in mdi (visibility of methods).
-OnModified method for IResizeFrame

........
sparta: MDI
-simulate MDI forms order for TMultiplyResizer
-property DesignedForm: IDesignedForm for IResizeFrame
........
sparta:
-IMPORTANT! pixel perfect form resizing (fix for problems for controls with align alLeft, alRight etc on design form).
-Fix problem for windows: wrong design design window width (a little bigger than designed size) TFormImpl.SetRealBounds -> AdjustSize
........
sparta: mdi bug fix for AV in TMultiplyResizer
........
Fix compilation for FPC 3.0 (TRect changes in FPC 3.1 trunk)
........
sparta: Cannot resize the docked form designer, issue #29380 patch from Anthony Walter. Thanks!
........
sparta ToolsAPI: Delphi compatible ToolsAPI/DesignIDE interface at XE2 level (proxy for IDEIntf). Initial commit (no functionality yet), just interfaces and classes without implementation:

designeditors.pas:
-TComponentEditor

designintf.pas:
-Interfaces: IEventInfo, IClass, IActivatable, IDesignObject, IDesignPersistent, IDesignerSelections, IDesigner60, IDesigner70, IDesigner80, IDesigner100, IDesigner, IComponentEditor
-TBaseComponentEditor
-RegisterComponentEditor

designmenus.pas:
-Interfaces: IMenuItems, IMenu, IMainMenu, IPopupMenu, IMenuItem

 
 


........
when form is removed we need to remove all handlers located in collections FFormsStack and FForms. Necessary to avoid AV.
........
sparta: more correct and simpler calculation of form border for Windows
........
sparta: 
  * Fix for loop error for resize. Highly visible problem for docked forms/frames with Align=alClient. 
  * New THookFrame class as new meta class for Frames.
........
updated lpl
........

git-svn-id: trunk@52728 -
2016-07-20 10:40:03 +00:00

56 lines
1.8 KiB
ObjectPascal

// Generic types for FreeSparta.com and FreePascal!
// by Maciej Izak (hnb), 2014
program THashMapCaseInsensitive;
{$MODE DELPHI}
{$APPTYPE CONSOLE}
uses
Generics.Collections, Generics.Defaults;
var
StringMap: THashMap<String, TEmptyRecord>;
AnsiStringMap: THashMap<AnsiString, TEmptyRecord>;
UnicodeStringMap: THashMap<UnicodeString, TEmptyRecord>;
AdvancedHashMapWithBigLoadFactor: TCuckooD6<RawByteString, TEmptyRecord>;
k: String;
begin
WriteLn('Working with case insensitive THashMap');
WriteLn;
// example constructors for different string types
StringMap := THashMap<String, TEmptyRecord>.Create(TIStringComparer.Ordinal);
StringMap.Free;
AnsiStringMap := THashMap<AnsiString, TEmptyRecord>.Create(TIAnsiStringComparer.Ordinal);
AnsiStringMap.Free;
UnicodeStringMap := THashMap<UnicodeString, TEmptyRecord>.Create(TIUnicodeStringComparer.Ordinal);
UnicodeStringMap.Free;
// standard TI*Comparer is dedicated for MAX_HASHLIST_COUNT = 4 and lower. For example DArrayCuckoo where D = 6
// we need to create extra specialized TGIStringComparer type
AdvancedHashMapWithBigLoadFactor := TCuckooD6<RawByteString, TEmptyRecord>.Create(
TGIStringComparer<RawByteString, TDelphiSixfoldHashFactory>.Ordinal);
AdvancedHashMapWithBigLoadFactor.Free;
// ok lets start
// another way to create case insensitive hash map
StringMap := THashMap<String, TEmptyRecord>.Create(TGIStringComparer<String>.Ordinal);
WriteLn('Add Cat and Dog');
StringMap.Add('Cat', EmptyRecord);
StringMap.Add('Dog', EmptyRecord);
//
WriteLn('Contains CAT = ', StringMap.ContainsKey('CAT'));
WriteLn('Contains dOG = ', StringMap.ContainsKey('dOG'));
WriteLn('Contains Fox = ', StringMap.ContainsKey('Fox'));
WriteLn('Enumerate all keys :');
for k in StringMap.Keys do
WriteLn(' > ', k);
ReadLn;
StringMap.Free;
end.