Sgss_Collection_Array_Map
Represents an associated collection array between keys and values

Description

Class diagram:
Sgss_Collection_Map_Abstract
 + Sgss_Collection_Array_Map
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/Map.php (line 46)

Class overview

Variables

protected array $_keys

Keys and the indices of the associated values

protected int $_size

The number of associations in this map

protected array $_values

Values associated with the keys

Methods

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

The constructor

boolean clear ()

Removes all the keys and the associated values in this map

mixed current ()
mixed|null get (mixed $key)

Returns the value associated with the specified key

boolean has (mixed $key)

Determines whether this map contains the associated value with the specified key

boolean hasValue (mixed $value)

Determines whether this map contains the specified value

mixed key ()
mixed next ()
boolean put (mixed $key, mixed $value)

Inserts or replaces the association between the specified key and value into this map

boolean remove (mixed $key)

Removes the specified key and the associated value from this map

void rewind ()
int size ()

Returns the number of associations between key and value in this map

array toArray ()

Converts this map to an associated array

array toKeyArray ()

Returns an array containing all the keys in this map

array toValueArray ()

Returns an array containing all the values in this map

boolean valid ()
Inherited from Sgss_Collection_Map_Abstract:
count(), hasAll(), hasAllValues(), isEmpty(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), putAll(), removeAll(), set(), __get(), __isset(), __set(), __unset()

Variable detail

$_keys 

Keys and the indices of the associated values

Signature:
protected array $_keys


$_size 

The number of associations in this map

Signature:
protected int $_size = 0


$_values 

Values associated with the keys

Signature:
protected array $_values


Method detail

__construct

The constructor

Parameters:
  • array|object|null $map

    Object containing keys and the asscociated values to be stored

Uses:
Sgss_Collection_Map_Abstract::putAll()
Signature:
public __construct ([array|object|null $map = null])


clear

Removes all the keys and the associated values in this map

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


current

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


get

Returns the value associated with the specified key

Parameters:
  • mixed $key

    Key associated with the value to be retrieved

Returns:
mixed|null -- Retrieved value or null if this map does not contain the key
Uses:
array_search()
Related subject:
Sgss_Collection_Map_Interface::get()
Signature:
public mixed|null get (mixed $key)


has

Determines whether this map contains the associated value with the specified key

Parameters:
  • mixed $key

    Key to determine

Returns:
boolean -- True when this map contains the associated value
Uses:
array_search()
Related subject:
Sgss_Collection_Map_Interface::has()
Signature:
public boolean has (mixed $key)


hasValue

Determines whether this map contains the specified value

Parameters:
  • mixed $value

    Value to determine

Returns:
boolean -- True when this map contains the value
Uses:
array_search()
Related subject:
Sgss_Collection_Map_Interface::hasValue()
Signature:
public boolean hasValue (mixed $value)


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 ()


put

Inserts or replaces the association between the specified key and value into this map

Parameters:
  • mixed $key

    Key to be inserted

  • mixed $value

    Value to be inserted and associated with the key

Returns:
boolean -- True when the operation changed this map
Uses:
array_search()
Related subject:
Sgss_Collection_Map_Interface::put()
Signature:
public boolean put (mixed $key, mixed $value)


remove

Removes the specified key and the associated value from this map

Parameters:
  • mixed $key

    Key associated with the value to be removed

Returns:
boolean -- True when the operation changed this list
Uses:
array_search()
Related subject:
Sgss_Collection_Map_Interface::remove()
Signature:
public boolean remove (mixed $key)


rewind

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


size

Returns the number of associations between key and value in this map

Returns:
int -- The number of associations in this map
Related subject:
Sgss_Collection_Map_Interface::size()
Signature:
public int size ()


toArray

Converts this map to an associated array

Returns:
array -- Associated array representing this map
Related subject:
Sgss_Collection_Map_Interface::toArray()
Signature:
public array toArray ()


toKeyArray

Returns an array containing all the keys in this map

Returns:
array -- Array containing all the keys in this map
Related subject:
Sgss_Collection_Map_Interface::toKeyArray()
Signature:
public array toKeyArray ()


toValueArray

Returns an array containing all the values in this map

Returns:
array -- Array containing all the values in this map
Related subject:
Sgss_Collection_Map_Interface::toValueArray()
Signature:
public array toValueArray ()


valid

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