The Set class

(No version information available, might only be in Git)

Introducere

A Set is a sequence of unique values. This implementation uses the same hash table as Ds\Map, where values are used as keys and the mapped value is ignored.

Strengths

  • Values can be any type, including objects.
  • Supports array syntax (square brackets).
  • Insertion order is preserved.
  • Automatically frees allocated memory when its size drops low enough.
  • add(), remove() and contains() are all O(1).

Weaknesses

  • Doesn’t support push(), pop(), insert(), shift(), or unshift().
  • get() is O(n) if there are deleted values in the buffer before the accessed index, O(1) otherwise.

Sinopsisul clasei

Ds\Set implements Ds\Collection {
/* Constants */
const int MIN_CAPACITY = 16 ;
/* Metode */
public add ([ mixed $...values ] ) : void
public allocate ( int $capacity ) : void
public capacity ( void ) : int
public clear ( void ) : void
public contains ([ mixed $...values ] ) : bool
public copy ( void ) : Ds\Set
public diff ( Ds\Set $set ) : Ds\Set
public filter ([ callable $callback ] ) : Ds\Set
public first ( void ) : mixed
public get ( int $index ) : mixed
public intersect ( Ds\Set $set ) : Ds\Set
public isEmpty ( void ) : bool
public join ([ string $glue ] ) : string
public last ( void ) : void
public merge ( mixed $values ) : Ds\Set
public reduce ( callable $callback [, mixed $initial ] ) : mixed
public remove ([ mixed $...values ] ) : void
public reverse ( void ) : void
public reversed ( void ) : Ds\Set
public slice ( int $index [, int $length ] ) : Ds\Set
public sort ([ callable $comparator ] ) : void
public sorted ([ callable $comparator ] ) : Ds\Set
public sum ( void ) : number
public toArray ( void ) : array
public union ( Ds\Set $set ) : Ds\Set
public xor ( Ds\Set $set ) : Ds\Set
}

Constante predefinite

Ds\Set::MIN_CAPACITY

Cuprins