Sgss_Collection_Array_Set
Represents a collection array without duplicated element

Description

Class diagram:
Sgss_Collection_Set_Abstract
 + Sgss_Collection_Array_Set
Implements:
Iterator (internal interface)
Author:
Matsuda Shota
Copyright:
(c) 2007-2008 Matsuda Shota
License:
http://creativecommons.org/licenses/GPL/2.0/
Located in:
/Collection/Array/Set.php (line 46)

Class overview

Variables

protected array $_elements

Elements in this set

protected int $_size

The number of the elements in this set

Methods

__construct ([array|object|null $elements = null])

The constructor

boolean add (array|Traversable $element, array|Traversable $t)

Adds all the elements in the specified value in this set

boolean clear ()

Removes all the elements in this set

mixed current ()
boolean has (mixed $element)

Determines whether this set contains the specified element

mixed key ()
mixed next ()
boolean remove (mixed $element)

Removes the element from this set

void rewind ()
int size ()

Returns the number of elements in this set

array toArray ()

Converts this set to an array

boolean valid ()
Inherited from Sgss_Collection_Set_Abstract:
addAll(), count(), hasAll(), isEmpty(), removeAll()

Variable detail

$_elements 

Elements in this set

Signature:
protected array $_elements


$_size 

The number of the elements in this set

Signature:
protected int $_size = 0


Method detail

__construct

The constructor

Parameters:
  • array|object|null $elements

    Value containing the elements to be stored

Uses:
Sgss_Collection_Set_Abstract::addAll()
Signature:
public __construct ([array|object|null $elements = null])


add

Adds all the elements in the specified value in this set

Parameters:
  • array|Traversable $t

    Value containing the elements to be added

  • $element
Returns:
boolean -- True when the operation changed this set
Related subject:
Sgss_Collection_Set_Interface::add()
Signature:
public boolean add (array|Traversable $element, array|Traversable $t)


clear

Removes all the elements in this set

Returns:
boolean -- True when the operation changed this set
Related subject:
Sgss_Collection_Set_Interface::clear()
Signature:
public boolean clear ()


current

Specified by:
  • Iterator::current
Related subject:
Iterator::current()
Signature:
public mixed current ()


has

Determines whether this set contains the specified element

Parameters:
  • mixed $element

    Element to determine

Returns:
boolean -- True when this set contains the element
Uses:
array_search()
Related subject:
Sgss_Collection_Set_Interface::has()
Signature:
public boolean has (mixed $element)


key

Specified by:
  • Iterator::key
Related subject:
Iterator::key()
Signature:
public mixed key ()


next

Specified by:
  • Iterator::next
Related subject:
Iterator::next()
Signature:
public mixed next ()


remove

Removes the element from this set

Parameters:
  • mixed $element

    Element to be removed

Returns:
boolean -- True when the operation changed this set
Uses:
array_search()
Related subject:
Sgss_Collection_Set_Interface::remove()
Signature:
public boolean remove (mixed $element)


rewind

Specified by:
  • Iterator::rewind
Related subject:
Iterator::rewind()
Signature:
public void rewind ()


size

Returns the number of elements in this set

Returns:
int -- The number of elements in this set
Related subject:
Sgss_Collection_Set_Interface::size()
Signature:
public int size ()


toArray

Converts this set to an array

Returns:
array -- Array representing this set
Related subject:
Sgss_Collection_Set_Interface::toArray()
Signature:
public array toArray ()


valid

Specified by:
  • Iterator::valid
Related subject:
Iterator::valid()
Signature:
public boolean valid ()