License:
see license.txt

  • class ArrayList (V): Keyed!(uint,V), List!(V);
  • This class is a wrapper around an array which provides the necessary implemenation to implement the List interface

    Adding or removing any element invalidates all cursors.

    This class serves as the gateway between builtin arrays and dcollection classes. You can construct an ArrayList with a builtin array serving as the storage, and you can access the ArrayList as an array with the asArray function. Neither of these make copies of the array, so you can continue to use the array in both forms.


  • int purge (int delegate(ref bool doRemove, ref V value) dg);
  • Iterate over the elements in the ArrayList, telling it which ones should be removed

    Use like this:

     // remove all odd elements
     foreach(ref doRemove, v; &arrayList.purge)
     {
       doRemove = (v & 1) != 0;
     }
    


  • int keypurge (int delegate(ref bool doRemove, ref uint key, ref V value) dg);
  • Iterate over the elements in the ArrayList, telling it which ones should be removed.

    Use like this:
     // remove all odd indexes
     foreach(ref doRemove, k, v; &arrayList.purge)
     {
       doRemove = (k & 1) != 0;
     }
    


  • struct cursor ;
  • The array cursor is exactly like a pointer into the array. The only difference between an ArrayList cursor and a pointer is that the ArrayList cursor provides the value property which is common throughout the collection package.

    All operations on the cursor are O(1)

  • V value ();
  • get the value pointed to

  • V value (V v);
  • set the value pointed to

  • cursor opPostInc ();
  • increment this cursor, returns what the cursor was before incrementing.

  • cursor opPostDec ();
  • decrement this cursor, returns what the cursor was before decrementing.

  • cursor opAddAssign (int inc);
  • increment the cursor by the given amount.

  • cursor opSubAssign (int inc);
  • decrement the cursor by the given amount.

  • cursor opAdd (int inc);
  • return a cursor that is inc elements beyond this cursor.

  • cursor opSub (int inc);
  • return a cursor that is inc elements before this cursor.

  • int opSub (cursor it);
  • return the number of elements between this cursor and the given cursor. If it points to a later element, the result is negative.

  • int opCmp (cursor it);
  • compare two cursors.

  • bool opEquals (cursor it);
  • compare two cursors for equality.

  • this();
  • create a new empty ArrayList

  • this(V[] storage);
  • Use an array as the backing storage. This does not duplicate the array. Use new ArrayList(storage.dup) to make a distinct copy.

  • ArrayList!(V) clear ();
  • clear the container of all values

  • uint length ();
  • return the number of elements in the collection

  • cursor begin ();
  • return a cursor that points to the first element in the list.

  • cursor end ();
  • return a cursor that points to just beyond the last element in the list.

  • cursor remove (cursor start, cursor last);
  • remove all the elements from start to last, not including the element pointed to by last. Returns a valid cursor that points to the element last pointed to.

    Runs in O(n) time.

  • cursor remove (cursor elem);
  • remove the element pointed to by elem. Equivalent to remove (elem, elem + 1).

    Runs in O(n) time

  • ArrayList!(V) remove (V v, ref bool wasRemoved);
  • remove an element with the specific value. This is an O(n) operation. If the collection has duplicate instances, the first element that matches is removed.

    returns this.

    Sets wasRemoved to true if the element existed and was removed.


  • ArrayList!(V) remove (V v);
  • remove an element with the specific value. This is an O(n) operation. If the collection has duplicate instances, the first element that matches is removed.

    returns this.

  • cursor find (cursor it, V v);
  • same as find (v), but start at given position.

  • cursor find (V v);
  • find the first occurrence of an element in the list. Runs in O(n) time.

  • bool contains (V v);
  • returns true if the collection contains the value. Runs in O(n) time.

  • ArrayList!(V) removeAt (uint key, ref bool wasRemoved);
  • remove the element at the given index. Runs in O(n) time.

  • ArrayList!(V) removeAt (uint key);
  • remove the element at the given index. Runs in O(n) time.

  • V opIndex (uint key);
  • get the value at the given index.

  • V opIndexAssign (V value, uint key);
  • set the value at the given index.

  • ArrayList!(V) set (uint key, V value, ref bool wasAdded);
  • set the value at the given index

  • ArrayList!(V) set (uint key, V value);
  • set the value at the given index

  • int opApply (int delegate(ref V value) dg);
  • iterate over the collection

  • int opApply (int delegate(ref uint key, ref V value) dg);
  • iterate over the collection with key and value

  • bool containsKey (uint key);
  • returns true if the given index is valid

    Runs in O(1) time

  • ArrayList!(V) add (V v, ref bool wasAdded);
  • add the given value to the end of the list. Always returns true.

  • ArrayList!(V) add (V v);
  • add the given value to the end of the list.

  • ArrayList!(V) add (Iterator!(V) coll);
  • adds all elements from the given iterator to the end of the list.

  • ArrayList!(V) add (Iterator!(V) coll, ref uint numAdded);
  • adds all elements from the given iterator to the end of the list.

  • ArrayList!(V) add (V[] array);
  • appends the array to the end of the list

  • ArrayList!(V) add (V[] array, ref uint numAdded);
  • appends the array to the end of the list

  • ArrayList!(V) opCatAssign (List!(V) rhs);
  • append another list to the end of this list

  • ArrayList!(V) opCatAssign (V[] array);
  • append an array to the end of this list

  • ArrayList!(V) opCat (List!(V) rhs);
  • returns a concatenation of the array list and another list.

  • ArrayList!(V) opCat (V[] array);
  • returns a concatenation of the array list and an array.

  • ArrayList!(V) opCat_r (V[] array);
  • returns a concatenation of the array list and an array.

  • uint count (V v);
  • returns the number of instances of the given element value

    Runs in O(n) time.

  • ArrayList!(V) removeAll (V v, ref uint numRemoved);
  • removes all the instances of the given element value

    Runs in O(n) time.

  • ArrayList!(V) removeAll (V v);
  • removes all the instances of the given element value

    Runs in O(n) time.

  • ArrayList!(V) opSlice (uint b, uint e);
  • Returns a slice of an array list. A slice can be used to view elements, remove elements, but cannot be used to add elements.

    The returned slice begins at index b and ends at, but does not include, index e.

  • ArrayList!(V) opSlice (cursor b, cursor e);
  • Slice an array given the cursors

  • ArrayList!(V) dup ();
  • Returns a copy of an array list

  • V[] asArray ();
  • get the array that this array represents. This is NOT a copy of the data, so modifying elements of this array will modify elements of the original ArrayList. Appending elements from this array will not affect the original array list just like appending to an array will not affect the original.

  • int opEquals (Object o);
  • operator to compare two objects.

    If o is a List!(V), then this does a list compare. If o is null or not an ArrayList, then the return value is 0.

  • int opEquals (V[] array);
  • Compare to a V array.

    equivalent to asArray == array.

  • V front ();
  • Look at the element at the front of the ArrayList.

  • V back ();
  • Look at the element at the end of the ArrayList.

  • V takeFront ();
  • Remove the element at the front of the ArrayList and return its value. This is an O(n) operation.

  • V takeBack ();
  • Remove the element at the end of the ArrayList and return its value. This can be an O(n) operation.

  • uint indexOf (V v);
  • Get the index of a particular value. Equivalent to find(v) - begin.

    If the value isn't in the collection, returns length.

  • ArrayList sort (int delegate(ref V v1, ref V v2) comp);
  • Sort according to a given comparison function

  • ArrayList sort (int(* comp)(ref V v1, ref V v2));
  • Sort according to a given comparison function

  • ArrayList sort ();
  • Sort according to the default comparison routine for V

    (C) 2008 by Steven Schveighoffer. All rights reserved :: page rendered by CandyDoc