⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decal.pas

📁 C++中的STL真的让人爱不释手,如果你使用DELPHI,现在你也有了类似于STL的标准库,还不赶快下载啊!
💻 PAS
📖 第 1 页 / 共 5 页
字号:

    {** Determine if this container has an object matching obj. }
		function _contains(const obj : DObject) : Boolean; virtual;

    {** Determine if this container has an object matching any of objs. }
    function contains(objs : array of const) : Boolean; virtual;

    {** Determine the number of items matching obj. }
		function _count(const obj : DObject) : Integer; virtual;

    {** Determine the total number of items matching objs. }
    function count(objs : array of const) : Integer; virtual;

    {** Does this container use pairs?}
    function usesPairs : Boolean; virtual;


    {** A comparator that uses hashes to differentiate objects. }
		function hashComparator(const obj1, obj2 : DObject) : Integer;

    {** A comparator that compares strings without case sensitivity. }
		function CaselessStringComparator(const obj1, obj2 : DObject) : Integer;

    {** The standard comparator that can compare all atomic types. }
		function DObjectComparator(const obj1, obj2 : DObject) : Integer;

    {** Creates this container using the specified comparator for ordering
    elements. }
		constructor createWith(compare : DComparator); virtual;

    {** Creates this container using the default comparator (DObjectComparator). }
		constructor create; virtual;

	end;

  DContainerClass = class of DContainer;

	////////////////////////////////////////////////////////////////////
	//
	// Container Adapters
	//
	////////////////////////////////////////////////////////////////////

  {** A container adapter is used to give a container a certain kind of
  interface.  For example, by using the DStack adapter, any sequential
  container can be made to have stack-like behavior.  All adapter classes
  should descend from DAdapter.  }
	DAdapter = class(DContainer)
  protected
  	FContainer : DContainer;  // the container we are wrapping.
  public
  	// constructor CreateOn(cont : DContainer);
  end;

  DAdapterClass = class of DAdapter;

  DStack = class(DAdapter)
  public
  {
  	procedure _Push(const obj : DObject); virtual;
    procedure Push(obj : array of const); virtual;
    function _Pop : DObject; virtual;
    function PopXXX...
  }
  end;

  DQueue = class(DAdapter)
  end;

	////////////////////////////////////////////////////////////////////
	//
	// Sequences
	//
	////////////////////////////////////////////////////////////////////

  {** DSequence is an abstract base class for containers that hold their
  items in a defined order. }
	DSequence = class(DContainer)
  public

  	// Container overrides

  	{** Add a DObject to this container.  The object is copied and added to
    the container.

    	@param	obj				The object to add.

    }
		procedure _add(const obj : DObject); override;

    {** Removes an object, by value, from this sequence. }
		procedure _remove(const obj : DObject); override;

    // DSequence stuff
    {** Return the item at the given position.  Note that returning this item
    may or may not be an efficient implementation.  DVector-based structures
    will be more efficient. The returned object can be converted with a toXXX
    function. }
		function at(pos : Integer) : DObject; virtual;

    {** Return a reference to the DObject at the given position.  }
    function atRef(pos : Integer) : PDObject; virtual;

    {** Return a reference to the last item in the sequence. }
		function backRef : PDObject; virtual;

    {** Return the last item in the sequence.  This returned item must be
    correctly disposed of, or converted with a toXXX function. }
    function back : DObject; virtual;

    {** Count the number of times an item occurs in a given range. }
		function _countWithin(_begin, _end : Integer; const obj : DObject) : Integer; virtual;

    {** Count the number of times an item occurs in a given range. }
		function countWithin(_begin, _end : Integer; objs : array of const) : Integer; virtual;

		{** Return a reference to the first object in the sequence. }
		function frontRef : PDObject; virtual;

    {** Return the first object in the sequence.  This value must be cleaned
    up or converted with a toXXX function. }
    function front : DObject; virtual;

    {** Find out where obj is in the collection.  Returns -1 if not found. }
		function _indexOf(const obj : DObject) : Integer; virtual;

    {** Find out where obj is in the collection.  Returns -1 if not found. }
		function indexOf(objs : array of const) : Integer; virtual;

    {** Find out where obj is within the given range..  Returns -1 if not found. }
		function _indexOfWithin(_begin, _end : Integer; const obj : DObject) : Integer; virtual;

    {** Find out where obj is within the given range..  Returns -1 if not found. }
		function indexOfWithin(_begin, _end : Integer; objs : array of const) : Integer; virtual;

    {** Set the item at a given position. }
		procedure _putAt(index : Integer; const obj : DObject); virtual;

    {** Set the item at a given position. }
    procedure putAt(index : Integer; objs : array of const); virtual;

    {** Remove count items an iterator is positioned at. All following items
    move up by count. }
    function removeAtIter(iter : DIterator; count : Integer) : DIterator; virtual; abstract;

    {** Replace every occurrence of obj1 with obj2 in the sequence.  Copies
    will be made of obj2. }
		procedure _replace(obj1, obj2 : DObject); virtual;

    {** Replace sources with targets, pairwise.  That is, the first element in
    sources will be replaced with the first in targets, the second in sources
    with the second in targets, and so on. }
    procedure replace(sources, targets : array of const); virtual;


    {** Replace sources with targets, pairwise, in the specified range.  That is, the first element in
    sources will be replaced with the first in targets, the second in sources
    with the second in targets, and so on. }
		procedure _replaceWithin(_begin, _end : Integer; obj1, obj2 : DObject); virtual;

		{** Replace sources with targets, pairwise, in the specified range.  That is, the first element in
    sources will be replaced with the first in targets, the second in sources
    with the second in targets, and so on. }
		procedure replaceWithin(_begin, _end : Integer; sources, targets : array of const); virtual;

    {** Remove every occurrence of the specified object within the given range. }
		procedure _removeWithin(_begin, _end : Integer; const obj : DObject); virtual; abstract;

    {** Remove every occurrence of each of the specified objects within the given range. }
		procedure removeWithin(_begin, _end : Integer; objs : array of const); virtual;

		{** Remove the last element in the sequence, returning its value. That value
    must be cleaned up or converted with a toXXX function. }
		function popBack : DObject; virtual; abstract;

		{** Remove the first element in the sequence, returning its value. That value
    must be cleaned up or converted with a toXXX function. }
		function popFront : DObject; virtual; abstract;

    {** Push an object to the back of the sequence.  The object will be copied. }
		procedure _pushBack(const obj : DObject); virtual; abstract;

    {** Push values to the back of the container.  The values will push in the
    order specified in the array. }
		procedure pushBack(objs : array of const); virtual;

    {** Push an object to the front of the container. }
		procedure _pushFront(const obj : DObject); virtual; abstract;

    {** Push values to the front of the container.  The values will appear at
    the front of the container in the order given. }
		procedure pushFront(objs : array of const); virtual;

    {** Retrieves at an index as an integer. Asserts if the type is not correct. }
    function atAsInteger(pos : Integer) : Integer;
    {** Retrieves at an index as a Boolean. Asserts if the type is not correct. }
    function atAsBoolean(pos : Integer) : Boolean;
		{** Retrieves at an index as a Char. Asserts if the type is not correct. }
    function atAsChar(pos : Integer) : Char;
    {** Retrieves at an index as an extended floating point value. Asserts if the type is not correct. }
    function atAsExtended(pos : Integer) : Extended;
    {** Retrieves at an index as a short string.Asserts if the type is not correct. }
    function atAsShortString(pos : Integer) : ShortString;
    {** Retrieves at an index as an untyped pointer.Asserts if the type is not correct. }
		function atAsPointer(pos : Integer) : Pointer;
    {** Retrieves at an index as a PChar. Asserts if the type is not correct. }
    function atAsPChar(pos : Integer) : PChar;
    {** Retrieves at an index as an object reference.  Asserts if the type is not correct. }
    function atAsObject(pos : Integer) : TObject;
    {** Retrieves at an index as a class reference (TClass). Asserts if the type is not correct. }
    function atAsClass(pos : Integer) : TClass;
    {** Retrieves at an index as a WideChar. Asserts if the type is not correct. }
    function atAsWideChar(pos : Integer) : WideChar;
    {** Retrieves at an index as a pointer to a WideChar. Asserts if the type is not correct. }
    function atAsPWideChar(pos : Integer) : PWideChar;
    {** Retrieves at an index as a String (AnsiString). Asserts if the type is not correct. }
    function atAsString(pos : Integer) : String;
    {** Retrieves at an index as a currency value. Asserts if the type is not correct. }
    function atAsCurrency(pos : Integer) : Currency;
    {** Retrieves at an index as a variant. Asserts if the type is not correct. }
    function atAsVariant(pos : Integer) : Variant;
    {** Retrieves at an index as an interface pointer. Asserts if the type is not correct. }
    function atAsInterface(pos : Integer) : Pointer;
    {** Retrieves at an index as a WideString. Asserts if the type is not correct. }
		function atAsWideString(pos : Integer) : WideString;
{$IFDEF USELONGWORD}
		function atAsInt64(pos : Integer) : Int64;
{$ENDIF}

	protected
		function _at(pos : Integer) : PDObject; virtual;
	end;

	DSequenceClass = class of DSequence;

	{** DVector is an abstract base class for containers that hold their items
  in an integer-addressable sequence. }
	DVector = class(DSequence)
	public
		//
		// Deques and Arrays (which are both Vectors) can do these...
		//

    {** Returns the number of elements that can fit into this vector without
    any expansion. }
		function capacity : Integer; virtual; abstract;

    {** Inserts an object before the object the iterator is positioned over.
		If the iterator is atEnd, the object will be added at the end. }
		procedure _insertAtIter(iterator : DIterator; const obj : DObject); virtual; abstract;

    {** Inserts values before the object the iterator is positioned over.
    If the iterator is atEnd, the object will be added at the end. The values
    will appear in the order specified. }
		procedure insertAtIter(iterator : DIterator; objs : array of const); virtual;

		{** Inserts an object before the object at position index.
		If the iterator is atEnd, the object will be added at the end. }
		procedure _insertAt(index : Integer; const obj : DObject); virtual; abstract;

		{** Inserts values before the object at position index.
		If the iterator is atEnd, the object will be added at the end. The values
		will appear in the order specified. }
		procedure insertAt(index : Integer; objs : array of const); virtual;

		{** Inserts  count copies of obj before the object iterator is positioned at. }
		procedure _insertMultipleAtIter(iterator : DIterator; count : Integer; const obj : DObject); virtual; abstract;

		{** Inserts count copies of a value before the object the iterator is positioned at. }
		procedure insertMultipleAtIter(iterator : DIterator; count : Integer; obj : array of const); virtual;

		{** Inserts count copies of obj before the object at position index. }
		procedure _insertMultipleAt(index : Integer; count : Integer; const obj : DObject); virtual; abstract;

		{** Inserts count copies of a value before the object at position index. }
		procedure insertMultipleAt(index : Integer; count : Integer; obj : array of const); virtual;

		{** Inserts copies of the objects in a given range before the object the
		iterator is over. }
		procedure insertRangeAtIter(iterator : DIterator; _start, _finish : DIterator); virtual; abstract;

		{** Inserts copies of the objects in a given range before the object at position
		index. }
		procedure insertRangeAt(index : Integer; _start, _finish : DIterator); virtual; abstract;

		{** Determines if the given index is legal for this container.  Effectively checks
		if index is greater than zero and less than the number of items. }
		function legalIndex(index : Integer) : Boolean; virtual;

		{** Remove the object at the given index. }
		procedure removeAt(index : Integer); virtual; abstract;

		{** Remove all objects between two indicies. }
		procedure removeBetween(_begin, _end : Integer); virtual; abstract;

		{** Remove every occurrence of object between two indicies. }
		procedure _removeWithin(_begin, _end : Integer; const obj : DObject); override; abstract;

		{** Remove every occurence of a value between two indicies. }
		procedure removeWithin(_begin, _end : Integer; objs : array of const); override;

		{** Ensure that this vector can accomodate at least amount objects without
		expanding. }
		procedure setCapacity(amount : Integer); virtual; abstract;

	end;

	{** DArray is a classic vector of items.  Arrays have very fast indexed
	access to elements.  Very fast addition to the end is possible if you
	call the ensureCapacity method with the right number of elements before
	adding.  As additions are occurring, the DArray will adaptively resize
	itself based on a blocking factor.  DArrays will expand themselves by
	30% or so each time they run out of capacity. }
	DArray = class(DVector)

	protected
		items : PDObjectArray;
		cap, len, blocking : Integer;

		//function addressOf(index : Integer) : PDObject; virtual;
		function makeSpaceAt(index, count : Integer) : PDObject; virtual;
		procedure removeSpaceAt(index, count : Integer); virtual;
		function iterFor(index : Integer) : DIterator; virtual;

		//
		// Iterator manipulation.
		//
		procedure iadvance(var iterator : DIterator); override;
		procedure iadvanceBy(var iterator : DIterator; count : Integer); override;
		function iget(const iterator : DIterator) : PDObject; override;
		function iequals(const iter1, iter2 : DIterator) : Boolean; override;
		procedure iput(const iterator : DIterator; const obj : DObject); override;
		function iremove(const iterator : DIterator) : DIterator; override;
		function idistance(const iter1, iter2 : DIterator) : Integer; override;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -