Changeset 129 for Generics


Ignore:
Timestamp:
Jan 17, 2011, 6:55:36 AM (14 years ago)
Author:
george
Message:
Location:
Generics/TemplateGenerics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/GenericList.inc

    r114 r129  
    110110function TGList.Get(Index: TGListIndex): TGListItem;
    111111begin
     112  if (Index < 0) or (Index >= Count) then
     113    raise EListError.CreateFmt(SListIndexError, [Index]);
    112114  Result := FItems[Index];
    113115end;
     
    115117procedure TGList.Put(Index: TGListIndex; const AValue: TGListItem);
    116118begin
     119  if (Index < 0) or (Index >= Count) then
     120    raise EListError.CreateFmt(SListIndexError, [Index]);
    117121  FItems[Index] := AValue;
    118122end;
     
    175179  I := 0;
    176180  while I < Count do begin
    177     Items[I] := Source[I];
     181    FItems[I] := Source[I];
    178182    I := I + 1;
    179183  end;
     
    247251    raise EListError.CreateFmt(SListIndexError, [0])
    248252  else
    249     Result := Items[FCount - 1];
     253    Result := FItems[FCount - 1];
    250254end;
    251255
     
    255259    raise EListError.CreateFmt(SListIndexError, [0])
    256260  else
    257     Items[FCount - 1] := AValue;
     261    FItems[FCount - 1] := AValue;
    258262end;
    259263
     
    263267    raise EListError.CreateFmt(SListIndexError, [0])
    264268  else
    265     Result := Items[0];
     269    Result := FItems[0];
    266270end;
    267271
     
    271275    raise EListError.CreateFmt(SListIndexError, [0])
    272276  else
    273     Items[0] := AValue;
     277    FItems[0] := AValue;
    274278end;
    275279
     
    401405  I := 0;
    402406  while I < Count do begin
    403     Result := Result + Converter(Items[I]);
     407    Result := Result + Converter(FItems[I]);
    404408    if I < (Count - 1) then
    405409      Result := Result + Separator;
     
    469473  I := Start;
    470474  while I < Count do begin
    471     Items[I] := Value;
     475    FItems[I] := Value;
    472476    I := I + 1;
    473477  end;
  • Generics/TemplateGenerics/Specialized/SpecializedList.pas

    r112 r129  
    1919{$DEFINE TGListFromStringConverter := TListIntegerFromStringConverter}
    2020{$DEFINE TGListItemArray := TListIntegerItemArray}
     21{$DEFINE INTERFACE}
     22{$I 'GenericList.inc'}
     23
     24// TListBoolean<Integer, Boolean>
     25{$DEFINE TGListIndex := Integer}
     26{$DEFINE TGListItem := Boolean}
     27{$DEFINE TGList := TListBoolean}
     28{$DEFINE TGListSortCompare := TListBooleanSortCompare}
     29{$DEFINE TGListToStringConverter := TListBooleanToStringConverter}
     30{$DEFINE TGListFromStringConverter := TListBooleanFromStringConverter}
     31{$DEFINE TGListItemArray := TListBooleanItemArray}
    2132{$DEFINE INTERFACE}
    2233{$I 'GenericList.inc'}
     
    148159
    149160// TListSmallInt<Integer, SmallInt>
    150 {$DEFINE TGListIndex:=Integer}
    151 {$DEFINE TGListItem:=SmallInt}
    152 {$DEFINE TGList:=TListSmallInt}
    153 {$DEFINE TGListSortCompare:=TListSmallIntSortCompare}
    154 {$DEFINE TGListToStringConverter:=TListSmallIntToStringConverter}
    155 {$DEFINE TGListFromStringConverter:=TListSmallIntFromStringConverter}
     161{$DEFINE TGListIndex := Integer}
     162{$DEFINE TGListItem := SmallInt}
     163{$DEFINE TGList := TListSmallInt}
     164{$DEFINE TGListSortCompare := TListSmallIntSortCompare}
     165{$DEFINE TGListToStringConverter := TListSmallIntToStringConverter}
     166{$DEFINE TGListFromStringConverter := TListSmallIntFromStringConverter}
    156167{$DEFINE TGListItemArray := TListSmallIntItemArray}
     168{$DEFINE IMPLEMENTATION}
     169{$I 'GenericList.inc'}
     170
     171// TListBoolean<Integer, Boolean>
     172{$DEFINE TGListIndex := Integer}
     173{$DEFINE TGListItem := Boolean}
     174{$DEFINE TGList := TListBoolean}
     175{$DEFINE TGListSortCompare := TListBooleanSortCompare}
     176{$DEFINE TGListToStringConverter := TListBooleanToStringConverter}
     177{$DEFINE TGListFromStringConverter := TListBooleanFromStringConverter}
     178{$DEFINE TGListItemArray := TListBooleanItemArray}
    157179{$DEFINE IMPLEMENTATION}
    158180{$I 'GenericList.inc'}
Note: See TracChangeset for help on using the changeset viewer.