Changeset 423
- Timestamp:
- Sep 18, 2012, 8:17:09 AM (12 years ago)
- Location:
- Generics/NativeGenerics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/NativeGenerics/Demo/Demo.lpi
r379 r423 38 38 </Item2> 39 39 </RequiredPackages> 40 <Units Count="6 0">40 <Units Count="68"> 41 41 <Unit0> 42 42 <Filename Value="Demo.lpr"/> … … 346 346 <Filename Value="../Units/GenericList.pas"/> 347 347 <UnitName Value="GenericList"/> 348 <IsVisibleTab Value="True"/> 348 349 <EditorIndex Value="1"/> 349 350 <WindowIndex Value="0"/> 350 <TopLine Value=" 12"/>351 <CursorPos X=" 74" Y="43"/>352 <UsageCount Value="6 0"/>351 <TopLine Value="530"/> 352 <CursorPos X="1" Y="542"/> 353 <UsageCount Value="61"/> 353 354 <Loaded Value="True"/> 354 355 </Unit35> … … 356 357 <Filename Value="../Units/GenericMatrix.pas"/> 357 358 <UnitName Value="GenericMatrix"/> 358 <IsVisibleTab Value="True"/> 359 <EditorIndex Value="5"/> 360 <WindowIndex Value="0"/> 361 <TopLine Value="103"/> 362 <CursorPos X="5" Y="116"/> 363 <UsageCount Value="38"/> 359 <EditorIndex Value="13"/> 360 <WindowIndex Value="0"/> 361 <TopLine Value="94"/> 362 <CursorPos X="18" Y="118"/> 363 <UsageCount Value="39"/> 364 364 <Loaded Value="True"/> 365 365 </Unit36> … … 383 383 <Filename Value="../Units/GenericDictionary.pas"/> 384 384 <UnitName Value="GenericDictionary"/> 385 <EditorIndex Value=" 4"/>385 <EditorIndex Value="12"/> 386 386 <WindowIndex Value="0"/> 387 387 <TopLine Value="1"/> 388 388 <CursorPos X="1" Y="1"/> 389 <UsageCount Value=" 39"/>389 <UsageCount Value="40"/> 390 390 <Loaded Value="True"/> 391 391 </Unit39> … … 432 432 <Filename Value="../Units/GenericRange.pas"/> 433 433 <UnitName Value="GenericRange"/> 434 <EditorIndex Value=" 2"/>434 <EditorIndex Value="10"/> 435 435 <WindowIndex Value="0"/> 436 436 <TopLine Value="4"/> 437 437 <CursorPos X="6" Y="16"/> 438 <UsageCount Value=" 39"/>438 <UsageCount Value="40"/> 439 439 <Loaded Value="True"/> 440 440 </Unit45> … … 449 449 <Filename Value="../Units/GenericTree.pas"/> 450 450 <UnitName Value="GenericTree"/> 451 <EditorIndex Value=" 3"/>451 <EditorIndex Value="11"/> 452 452 <WindowIndex Value="0"/> 453 453 <TopLine Value="50"/> 454 454 <CursorPos X="49" Y="68"/> 455 <UsageCount Value=" 39"/>455 <UsageCount Value="40"/> 456 456 <Loaded Value="True"/> 457 457 </Unit47> … … 459 459 <Filename Value="../Units/GenericString.pas"/> 460 460 <UnitName Value="GenericString"/> 461 <EditorIndex Value=" 6"/>461 <EditorIndex Value="14"/> 462 462 <WindowIndex Value="0"/> 463 463 <TopLine Value="35"/> 464 464 <CursorPos X="23" Y="40"/> 465 <UsageCount Value="3 2"/>465 <UsageCount Value="33"/> 466 466 <Loaded Value="True"/> 467 467 </Unit48> … … 469 469 <Filename Value="../Units/GenericBitmap.pas"/> 470 470 <UnitName Value="GenericBitmap"/> 471 <EditorIndex Value=" 7"/>471 <EditorIndex Value="15"/> 472 472 <WindowIndex Value="0"/> 473 473 <TopLine Value="1"/> 474 474 <CursorPos X="15" Y="14"/> 475 <UsageCount Value="3 1"/>475 <UsageCount Value="32"/> 476 476 <Loaded Value="True"/> 477 477 </Unit49> … … 550 550 <UsageCount Value="28"/> 551 551 </Unit59> 552 <Unit60> 553 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/objpas/sysutils/filutilh.inc"/> 554 <EditorIndex Value="7"/> 555 <WindowIndex Value="0"/> 556 <TopLine Value="62"/> 557 <CursorPos X="3" Y="75"/> 558 <UsageCount Value="11"/> 559 <Loaded Value="True"/> 560 </Unit60> 561 <Unit61> 562 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/inc/systemh.inc"/> 563 <EditorIndex Value="2"/> 564 <WindowIndex Value="0"/> 565 <TopLine Value="1027"/> 566 <CursorPos X="11" Y="1040"/> 567 <UsageCount Value="11"/> 568 <Loaded Value="True"/> 569 </Unit61> 570 <Unit62> 571 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/win/sysutils.pp"/> 572 <UnitName Value="sysutils"/> 573 <EditorIndex Value="8"/> 574 <WindowIndex Value="0"/> 575 <TopLine Value="300"/> 576 <CursorPos X="1" Y="302"/> 577 <UsageCount Value="11"/> 578 <Loaded Value="True"/> 579 </Unit62> 580 <Unit63> 581 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/win/wininc/func.inc"/> 582 <EditorIndex Value="9"/> 583 <WindowIndex Value="0"/> 584 <TopLine Value="169"/> 585 <CursorPos X="15" Y="177"/> 586 <UsageCount Value="11"/> 587 <Loaded Value="True"/> 588 </Unit63> 589 <Unit64> 590 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/inc/file.inc"/> 591 <EditorIndex Value="4"/> 592 <WindowIndex Value="0"/> 593 <TopLine Value="299"/> 594 <CursorPos X="3" Y="304"/> 595 <UsageCount Value="11"/> 596 <Loaded Value="True"/> 597 </Unit64> 598 <Unit65> 599 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/win/sysfile.inc"/> 600 <EditorIndex Value="5"/> 601 <WindowIndex Value="0"/> 602 <TopLine Value="133"/> 603 <CursorPos X="11" Y="143"/> 604 <UsageCount Value="11"/> 605 <Loaded Value="True"/> 606 </Unit65> 607 <Unit66> 608 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/win/sysos.inc"/> 609 <EditorIndex Value="6"/> 610 <WindowIndex Value="0"/> 611 <TopLine Value="250"/> 612 <CursorPos X="20" Y="268"/> 613 <UsageCount Value="11"/> 614 <Loaded Value="True"/> 615 </Unit66> 616 <Unit67> 617 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/inc/text.inc"/> 618 <EditorIndex Value="3"/> 619 <WindowIndex Value="0"/> 620 <TopLine Value="108"/> 621 <CursorPos X="3" Y="110"/> 622 <UsageCount Value="10"/> 623 <Loaded Value="True"/> 624 </Unit67> 552 625 </Units> 553 626 <JumpHistory Count="30" HistoryIndex="29"> 554 627 <Position1> 555 <Filename Value="../Units/Generic Matrix.pas"/>556 <Caret Line="7 1" Column="45" TopLine="57"/>628 <Filename Value="../Units/GenericList.pas"/> 629 <Caret Line="744" Column="17" TopLine="737"/> 557 630 </Position1> 558 631 <Position2> 559 <Filename Value="../ Units/GenericMatrix.pas"/>560 <Caret Line=" 77" Column="43" TopLine="64"/>632 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/inc/file.inc"/> 633 <Caret Line="304" Column="3" TopLine="299"/> 561 634 </Position2> 562 635 <Position3> 563 <Filename Value="../ Units/GenericMatrix.pas"/>564 <Caret Line=" 87" Column="47" TopLine="74"/>636 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/win/sysfile.inc"/> 637 <Caret Line="173" Column="10" TopLine="160"/> 565 638 </Position3> 566 639 <Position4> 567 <Filename Value="../ Units/GenericMatrix.pas"/>568 <Caret Line=" 89" Column="62" TopLine="76"/>640 <Filename Value="../../../../../Lazarus/1.1_2.7.1/fpc/2.7.1/source/rtl/win/sysfile.inc"/> 641 <Caret Line="143" Column="11" TopLine="133"/> 569 642 </Position4> 570 643 <Position5> 571 <Filename Value="../Units/Generic Matrix.pas"/>572 <Caret Line=" 93" Column="59" TopLine="80"/>644 <Filename Value="../Units/GenericList.pas"/> 645 <Caret Line="26" Column="29" TopLine="12"/> 573 646 </Position5> 574 647 <Position6> 575 <Filename Value="../Units/Generic Matrix.pas"/>576 <Caret Line=" 94" Column="61" TopLine="81"/>648 <Filename Value="../Units/GenericList.pas"/> 649 <Caret Line="732" Column="24" TopLine="727"/> 577 650 </Position6> 578 651 <Position7> 579 <Filename Value="../Units/Generic Matrix.pas"/>580 <Caret Line=" 124" Column="73" TopLine="111"/>652 <Filename Value="../Units/GenericList.pas"/> 653 <Caret Line="23" Column="54" TopLine="12"/> 581 654 </Position7> 582 655 <Position8> 583 <Filename Value="../Units/Generic Matrix.pas"/>584 <Caret Line=" 140" Column="71" TopLine="127"/>656 <Filename Value="../Units/GenericList.pas"/> 657 <Caret Line="57" Column="1" TopLine="41"/> 585 658 </Position8> 586 659 <Position9> 587 <Filename Value="../Units/Generic Matrix.pas"/>588 <Caret Line=" 223" Column="57" TopLine="210"/>660 <Filename Value="../Units/GenericList.pas"/> 661 <Caret Line="324" Column="1" TopLine="311"/> 589 662 </Position9> 590 663 <Position10> 591 <Filename Value="../Units/Generic Matrix.pas"/>592 <Caret Line=" 311" Column="74" TopLine="298"/>664 <Filename Value="../Units/GenericList.pas"/> 665 <Caret Line="686" Column="6" TopLine="673"/> 593 666 </Position10> 594 667 <Position11> 595 <Filename Value="../Units/Generic Matrix.pas"/>596 <Caret Line=" 323" Column="59" TopLine="310"/>668 <Filename Value="../Units/GenericList.pas"/> 669 <Caret Line="694" Column="6" TopLine="681"/> 597 670 </Position11> 598 671 <Position12> 599 <Filename Value="../Units/Generic Matrix.pas"/>600 <Caret Line=" 431" Column="55" TopLine="418"/>672 <Filename Value="../Units/GenericList.pas"/> 673 <Caret Line="702" Column="6" TopLine="689"/> 601 674 </Position12> 602 675 <Position13> 603 <Filename Value="../Units/Generic Bitmap.pas"/>604 <Caret Line=" 14" Column="15" TopLine="1"/>676 <Filename Value="../Units/GenericList.pas"/> 677 <Caret Line="710" Column="6" TopLine="697"/> 605 678 </Position13> 606 679 <Position14> 607 <Filename Value="../Units/Generic Matrix.pas"/>608 <Caret Line=" 114" Column="55" TopLine="91"/>680 <Filename Value="../Units/GenericList.pas"/> 681 <Caret Line="21" Column="7" TopLine="14"/> 609 682 </Position14> 610 683 <Position15> 611 <Filename Value="../Units/Generic Matrix.pas"/>612 <Caret Line=" 50" Column="39" TopLine="37"/>684 <Filename Value="../Units/GenericList.pas"/> 685 <Caret Line="746" Column="37" TopLine="734"/> 613 686 </Position15> 614 687 <Position16> 615 <Filename Value="../Units/Generic Matrix.pas"/>616 <Caret Line=" 114" Column="24" TopLine="94"/>688 <Filename Value="../Units/GenericList.pas"/> 689 <Caret Line="52" Column="1" TopLine="37"/> 617 690 </Position16> 618 691 <Position17> 619 <Filename Value="../Units/Generic Matrix.pas"/>620 <Caret Line=" 50" Column="40" TopLine="25"/>692 <Filename Value="../Units/GenericList.pas"/> 693 <Caret Line="35" Column="14" TopLine="22"/> 621 694 </Position17> 622 695 <Position18> 623 <Filename Value="../Units/Generic Matrix.pas"/>624 <Caret Line=" 114" Column="24" TopLine="101"/>696 <Filename Value="../Units/GenericList.pas"/> 697 <Caret Line="716" Column="36" TopLine="715"/> 625 698 </Position18> 626 699 <Position19> 627 <Filename Value="../Units/Generic Matrix.pas"/>628 <Caret Line=" 50" Column="39" TopLine="37"/>700 <Filename Value="../Units/GenericList.pas"/> 701 <Caret Line="121" Column="1" TopLine="108"/> 629 702 </Position19> 630 703 <Position20> 631 <Filename Value="../Units/Generic Matrix.pas"/>632 <Caret Line=" 664" Column="1" TopLine="639"/>704 <Filename Value="../Units/GenericList.pas"/> 705 <Caret Line="130" Column="38" TopLine="108"/> 633 706 </Position20> 634 707 <Position21> 635 <Filename Value="../Units/Generic Matrix.pas"/>636 <Caret Line=" 132" Column="3" TopLine="114"/>708 <Filename Value="../Units/GenericList.pas"/> 709 <Caret Line="769" Column="58" TopLine="765"/> 637 710 </Position21> 638 711 <Position22> 639 <Filename Value="../Units/Generic Matrix.pas"/>640 <Caret Line="1 14" Column="14" TopLine="106"/>712 <Filename Value="../Units/GenericList.pas"/> 713 <Caret Line="131" Column="70" TopLine="119"/> 641 714 </Position22> 642 715 <Position23> 643 <Filename Value="../Units/Generic Matrix.pas"/>644 <Caret Line="13 3" Column="15" TopLine="115"/>716 <Filename Value="../Units/GenericList.pas"/> 717 <Caret Line="130" Column="36" TopLine="119"/> 645 718 </Position23> 646 719 <Position24> 647 <Filename Value="../Units/Generic Matrix.pas"/>648 <Caret Line=" 54" Column="65" TopLine="37"/>720 <Filename Value="../Units/GenericList.pas"/> 721 <Caret Line="771" Column="32" TopLine="765"/> 649 722 </Position24> 650 723 <Position25> 651 <Filename Value="../Units/Generic Matrix.pas"/>652 <Caret Line=" 50" Column="39" TopLine="37"/>724 <Filename Value="../Units/GenericList.pas"/> 725 <Caret Line="130" Column="15" TopLine="117"/> 653 726 </Position25> 654 727 <Position26> 655 <Filename Value="../Units/Generic Matrix.pas"/>656 <Caret Line=" 138" Column="50" TopLine="118"/>728 <Filename Value="../Units/GenericList.pas"/> 729 <Caret Line="725" Column="1" TopLine="716"/> 657 730 </Position26> 658 731 <Position27> 659 <Filename Value="../Units/Generic Matrix.pas"/>660 <Caret Line=" 144" Column="49" TopLine="120"/>732 <Filename Value="../Units/GenericList.pas"/> 733 <Caret Line="778" Column="9" TopLine="757"/> 661 734 </Position27> 662 735 <Position28> 663 <Filename Value="../Units/Generic Matrix.pas"/>664 <Caret Line=" 134" Column="1" TopLine="122"/>736 <Filename Value="../Units/GenericList.pas"/> 737 <Caret Line="773" Column="29" TopLine="754"/> 665 738 </Position28> 666 739 <Position29> 667 <Filename Value="../Units/Generic Matrix.pas"/>668 <Caret Line=" 137" Column="41" TopLine="126"/>740 <Filename Value="../Units/GenericList.pas"/> 741 <Caret Line="59" Column="24" TopLine="45"/> 669 742 </Position29> 670 743 <Position30> 671 <Filename Value="../Units/Generic Matrix.pas"/>672 <Caret Line=" 136" Column="29" TopLine="123"/>744 <Filename Value="../Units/GenericList.pas"/> 745 <Caret Line="35" Column="15" TopLine="23"/> 673 746 </Position30> 674 747 </JumpHistory> … … 740 813 </Exceptions> 741 814 </Debugging> 815 <EditorMacros Count="0"/> 742 816 </CONFIG> -
Generics/NativeGenerics/Units/GenericList.pas
r379 r423 20 20 TFromStringConverter = function(Text: string): TItem; 21 21 TItemArray = array of TItem; 22 pr ivate23 function GetLast: TItem; virtual; abstract;24 procedure SetLast( AValue: TItem); virtual; abstract;25 function GetFirst: TItem; virtual; abstract;26 procedure SetFirst( AValue: TItem); virtual; abstract;22 protected 23 function GetLast: TItem; virtual; 24 procedure SetLast(const AValue: TItem); virtual; 25 function GetFirst: TItem; virtual; 26 procedure SetFirst(const AValue: TItem); virtual; 27 27 function GetCount: TIndex; virtual; abstract; 28 28 procedure SetCount(const AValue: TIndex); virtual; abstract; … … 33 33 public 34 34 constructor Create; virtual; 35 function Add(Item: TItem): TIndex; virtual; abstract; 35 procedure Clear; virtual; 36 function Add(const Item: TItem): TIndex; virtual; 36 37 property Count: TIndex read GetCount write SetCount; 37 38 property Capacity: TIndex read GetCapacity write SetCapacity; … … 47 48 FCount: TIndex; 48 49 FItems: array of TItem; 50 protected 49 51 function Get(Index: TIndex): TItem; override; 50 52 function GetCapacity: TIndex; override; 51 function GetFirst: TItem; override;52 function GetLast: TItem; override;53 53 function GetCount: TIndex; override; 54 54 procedure SetCapacity(const AValue: TIndex); override; 55 55 procedure SetCapacityOptimized(const NewCapacity: TIndex); 56 56 procedure SetCount(const AValue: TIndex); override; 57 procedure SetFirst(AValue: TItem); override;58 procedure SetLast(AValue: TItem); override;59 57 procedure Put(Index: TIndex; const AValue: TItem); override; 60 58 procedure QuickSort(L, R : TIndex; Compare: TSortCompare); 61 59 public 62 function Add( Item: TItem): TIndex; override;60 function Add(const Item: TItem): TIndex; override; 63 61 procedure AddArray(Values: array of TItem); 64 62 procedure AddList(List: TGList<TItem>); 65 63 procedure AddListPart(List: TGList<TItem>; ItemIndex, ItemCount: TIndex); 66 64 procedure Assign(Source: TGList<TItem>); virtual; 67 procedure Clear; virtual;68 65 procedure Delete(Index: TIndex); virtual; 69 66 procedure DeleteItems(Index, Count: TIndex); … … 95 92 96 93 TGObjectList<TItem> = class(TGList<TItem>) 97 pr ivate94 protected 98 95 procedure Put(Index: Integer; const AValue: TItem); override; 99 96 public … … 112 109 procedure Clear; override; 113 110 procedure Assign(Source: TGList<TItem>); override; 111 constructor Create; override; 112 destructor Destroy; override; 113 end; 114 115 { TGFileList } 116 117 TGFileList<TItem> = class(TGList<TItem>) 118 private 119 FHandle: THandle; 120 protected 121 function GetCount: TIndex; override; 122 procedure SetCount(const AValue: TIndex); override; 123 procedure SetCapacity(const AValue: TIndex); override; 124 function GetCapacity: TIndex; override; 125 function Get(Index: TIndex): TItem; override; 126 procedure Put(Index: TIndex; const AValue: TItem); override; 127 public 128 procedure Open(FileName: string; Mode: Integer); 129 procedure Close; 114 130 constructor Create; 115 131 destructor Destroy; override; … … 117 133 118 134 135 resourcestring 136 SListIndexError = 'List index (%d) out of bounds'; 137 SListCapacityError = 'List capacity (%d) exceeded.'; 138 SListCountError = 'List count (%d) out of bounds.'; 139 119 140 implementation 120 121 uses122 RtlConsts;123 141 124 142 { TGList<TItem> } … … 298 316 end; 299 317 300 function TGList<TItem>.GetLast: TItem;301 begin302 if FCount = 0 then303 raise EListError.CreateFmt(SListIndexError, [0])304 else305 Result := FItems[FCount - 1];306 end;307 308 318 function TGList<TItem>.GetCount: TIndex; 309 319 begin 310 320 Result := FCount; 311 end;312 313 procedure TGList<TItem>.SetLast(AValue: TItem);314 begin315 if FCount = 0 then316 raise EListError.CreateFmt(SListIndexError, [0])317 else318 FItems[FCount - 1] := AValue;319 end;320 321 function TGList<TItem>.GetFirst: TItem;322 begin323 if FCount = 0 then324 raise EListError.CreateFmt(SListIndexError, [0])325 else326 Result := FItems[0];327 end;328 329 procedure TGList<TItem>.SetFirst(AValue: TItem);330 begin331 if FCount = 0 then332 raise EListError.CreateFmt(SListIndexError, [0])333 else334 FItems[0] := AValue;335 321 end; 336 322 … … 521 507 end; 522 508 523 function TGList<TItem>.Add( Item: TItem): TIndex;509 function TGList<TItem>.Add(const Item: TItem): TIndex; 524 510 begin 525 511 Count := Count + 1; 526 512 Result := FCount - 1; 527 FItems[Result] := Item;513 Items[Result] := Item; 528 514 end; 529 515 … … 552 538 J := J + 1; 553 539 end; 554 end;555 556 procedure TGList<TItem>.Clear;557 begin558 Count := 0;559 Capacity := 0;560 540 end; 561 541 … … 690 670 { TGAbstractList<TItem> } 691 671 672 function TGAbstractList<TItem>.GetLast: TItem; 673 begin 674 if Count = 0 then 675 raise EListError.CreateFmt(SListIndexError, [0]) 676 else 677 Result := Items[Count - 1]; 678 end; 679 680 procedure TGAbstractList<TItem>.SetLast(const AValue: TItem); 681 begin 682 if Count = 0 then 683 raise EListError.CreateFmt(SListIndexError, [0]) 684 else 685 Items[Count - 1] := AValue; 686 end; 687 688 function TGAbstractList<TItem>.GetFirst: TItem; 689 begin 690 if Count = 0 then 691 raise EListError.CreateFmt(SListIndexError, [0]) 692 else 693 Result := Items[0]; 694 end; 695 696 procedure TGAbstractList<TItem>.SetFirst(const AValue: TItem); 697 begin 698 if Count = 0 then 699 raise EListError.CreateFmt(SListIndexError, [0]) 700 else 701 Items[0] := AValue; 702 end; 703 692 704 constructor TGAbstractList<TItem>.Create; 693 705 begin 694 706 end; 695 707 708 procedure TGAbstractList<TItem>.Clear; 709 begin 710 Count := 0; 711 Capacity := 0; 712 end; 713 714 function TGAbstractList<TItem>.Add(const Item: TItem): TIndex; 715 begin 716 Count := Count + 1; 717 Result := Count - 1; 718 Items[Result] := Item; 719 end; 720 721 { TGFileList<TItem> } 722 723 function TGFileList<TItem>.GetCount: TIndex; 724 var 725 OldPos: TIndex; 726 begin 727 OldPos := FileSeek(FHandle, 0, 1); 728 Result := FileSeek(FHandle, 0, 2); 729 FileSeek(FHandle, OldPos, 0); 730 end; 731 732 procedure TGFileList<TItem>.SetCount(const AValue: TIndex); 733 begin 734 FileTruncate(FHandle, AValue); 735 end; 736 737 procedure TGFileList<TItem>.SetCapacity(const AValue: TIndex); 738 begin 739 inherited SetCapacity(AValue); 740 end; 741 742 function TGFileList<TItem>.GetCapacity: TIndex; 743 begin 744 Result := inherited GetCapacity; 745 end; 746 747 function TGFileList<TItem>.Get(Index: TIndex): TItem; 748 begin 749 FileSeek(FHandle, Index, 0); 750 FileRead(FHandle, Result, SizeOf(Result)); 751 end; 752 753 procedure TGFileList<TItem>.Put(Index: TIndex; const AValue: TItem); 754 begin 755 FileSeek(FHandle, Index, 0); 756 FileWrite(FHandle, AValue, SizeOf(AValue)); 757 end; 758 759 procedure TGFileList<TItem>.Open(FileName: string; Mode: Integer); 760 begin 761 Close; 762 if Mode = fmCreate then FHandle := FileCreate(FileName, Mode) 763 else FileOpen(FileName, Mode); 764 end; 765 766 procedure TGFileList<TItem>.Close; 767 begin 768 if FHandle <> feInvalidHandle then FileClose(FHandle); 769 end; 770 771 constructor TGFileList<TItem>.Create; 772 begin 773 FHandle := feInvalidHandle; 774 end; 775 776 destructor TGFileList<TItem>.Destroy; 777 begin 778 Close; 779 inherited; 780 end; 781 696 782 end. -
Generics/NativeGenerics/Units/GenericMatrix.pas
r379 r423 85 85 function Implode(RowSeparator, ColSeparator: string; Converter: TToStringConverter): string; 86 86 procedure Explode(Text, Separator: string; Converter: TFromStringConverter; SlicesCount: Integer = -1); 87 function IndexOf(Item: TItem; Start: TIndex = 0): TIndex;88 function IndexOfList(List: TGMatrix<TItem>; Start: TIndex = 0): TIndex;87 function IndexOf(Item: TItem; Start: TIndex): TIndex; 88 function IndexOfList(List: TGMatrix<TItem>; Start: TIndex): TIndex; 89 89 procedure Insert(Index: TIndex; Item: TItem); 90 90 procedure InsertList(Index: TIndex; List: TGMatrix<TItem>); -
Generics/NativeGenerics/Units/GenericString.pas
r324 r423 29 29 begin 30 30 for I := 0 to Count - 1 do 31 if (Items[I] in ['a'..'z']) then31 if (Items[I] >= 'a') and (Items[I] <= 'z') then 32 32 Items[I] := Char(Byte(Items[I]) - 32); 33 33 end; … … 38 38 begin 39 39 for I := 0 to Count - 1 do 40 if (Items[I] in ['A'..'Z']) then40 if (Items[I] >= 'A') and (Items[I] <= 'Z') then 41 41 Items[I] := Char(Byte(Items[I]) + 32); 42 42 end;
Note:
See TracChangeset
for help on using the changeset viewer.