Sign in Join
FPDoc Onlineexperiment

TWordList class

In unit IntegerList

Implements a specialization of TFPGList for the Word data type.

Declaration

pascal
TWordList = class()

Description

TWordList provides an overloaded Sort method to ensure that values in the list are handled using a compare function that operates on Word values. Internally, it provides a TFPGListEnumerator which is specialized for the Word type used in the implementation.

Use the properties and methods defined in the ancestor class to perform common operations for Word values, including:

  • Add
  • IndexOf
  • Insert
  • Extract
  • Remove
  • Sort
  • AddList
  • Assign
  • First
  • Last
  • Items
  • List

Items is the default property, and allows access to values by ordinal position or by using an enumerator to traverse the Word values in List.

// using TWordList properties and methods
// var
//    AWordList: TWordList;
//    AIndex, ACount: Integer;
//    AMax, AValue: Word;
AWordList := TWordList.Create;
AMax := High(Word);
AWordList.Add(Random(AMax));
AWordList.Add(Random(AMax));
AWordList.Add(Random(AMax));
AWordList.Add(Random(AMax));
AWordList.Insert(2, 42);
AWordList.Sort;
ACount := AWordList.Count;
AIndex := AWordList.IndexOf(AWordList.Last);
AValue := AWordList.Last;
AWordList.Last := AValue - 1;
AValue := AWordList.Extract(AInt64List.First);
AIndex := AWordList.Remove(42);
AWordList.Clear;
AWordList.Free;

See also

Methods

SortpublicSorts the Word values stored in the list.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.