Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

OHash Class Reference

List of all members.

Public Member Functions

 __construct ($array=array())
 OHash ($array=array())
 set ($key, $value)
 setRef ($key, &$value)
 setAll ($hash)
get ($key)
 remove ($key)
 removeElement (&$o)
 isEmpty ()
 size ()
values ()
 keys ()
 getNewIterator ()
 containsKey ($key)
 containsValue ($value)
toHash ()
 toString ()
 sort ()

Static Public Member Functions

 ArrayToHash ($array)

Public Attributes

 $_hash

Detailed Description

Wrapper for oriented object associative arrays.

This class implements a simple interface quite like java to handle associatives arrays (Hashtables).

Note:

Some problems may occurs with object references until php4.4 to avoid unwanted object copy, use setRef() method with objects or pass Ref objects to set().

Author:
Laurent Bedubourg <laurent.bedubourg@free.fr>

Definition at line 41 of file OHash.php.


Constructor & Destructor Documentation

OHash::OHash array = array()  ) 
 

OHash constructor.

php4.4 compliant constructor

Parameters:
array $array optional -- An associative php array

Definition at line 68 of file OHash.php.


Member Function Documentation

OHash::__construct array = array()  ) 
 

OHash constructor.

php4.4 compliant constructor

Parameters:
array $array optional -- An associative php array

Definition at line 52 of file OHash.php.

References __construct(), keys(), and ref().

Referenced by __construct().

OHash::ArrayToHash array  )  [static]
 

Create an Hash object from a simple php array variable.

This method assumes that the array is composed of serial key, value elements. For each pair of array element, the former will be used as key and the latter as value.

Parameters:
array $array -- php array.
Returns:
Hash 1

Definition at line 272 of file OHash.php.

References ArrayToHash().

Referenced by ArrayToHash().

OHash::containsKey key  ) 
 

Test if this hash contains specified key.

Parameters:
string $key
Returns:
boolean

Definition at line 225 of file OHash.php.

References containsKey().

Referenced by containsKey(), and get().

OHash::containsValue value  ) 
 

Test if this hash contains specified value.

Parameters:
mixed $value -- The value to search
Returns:
boolean

Definition at line 236 of file OHash.php.

References containsValue().

Referenced by containsValue().

& OHash::get key  ) 
 

Retrieve value associated to specified key.

Parameters:
string $key
Returns:
reference

Definition at line 119 of file OHash.php.

References containsKey(), and get().

Referenced by get().

OHash::getNewIterator  ) 
 

Retrieve an hash iterator ready to use.

Returns:
HashIterator

Definition at line 214 of file OHash.php.

OHash::isEmpty  ) 
 

Returns true is hashtable empty.

Returns:
boolean

Definition at line 170 of file OHash.php.

References size().

OHash::keys  ) 
 

Retrieve hash keys array.

Returns:
array

Definition at line 204 of file OHash.php.

Referenced by __construct(), remove(), and setAll().

OHash::remove key  ) 
 

Remove element associated to specified key from hash.

Parameters:
string $key

Definition at line 132 of file OHash.php.

References $i, keys(), and remove().

Referenced by remove().

OHash::removeElement &$  o  ) 
 

Remove an element from the Hash.

Parameters:
mixed $o -- Element to remove from Hash

Definition at line 149 of file OHash.php.

References $i, and removeElement().

Referenced by removeElement().

OHash::set key,
value
 

Set a value in this hash.

Parameters:
string $key
string $value

Definition at line 79 of file OHash.php.

References ref(), and set().

Referenced by set().

OHash::setAll hash  ) 
 

Set a map of values.

Parameters:
mixed $hash An Hash object or an associative php array.

Definition at line 102 of file OHash.php.

References keys(), ref(), and setAll().

Referenced by setAll().

OHash::setRef key,
&$  value
 

Reference set.

Until php4.4, it's the only way to avoid object/variable copy.

Parameters:
string $key
reference $value

Definition at line 92 of file OHash.php.

References ref(), and setRef().

Referenced by setRef().

OHash::size  ) 
 

Retrieve hash size (number of elements).

Returns:
int

Definition at line 180 of file OHash.php.

Referenced by isEmpty().

OHash::sort  ) 
 

Sort hashtable on its keys.

Definition at line 295 of file OHash.php.

& OHash::toHash  ) 
 

Returns the php array (hashtable) handled by this object.

Returns:
hashtable

Definition at line 251 of file OHash.php.

OHash::toString  ) 
 

Generate and return a string representation of this hashtable.

Returns:
string

Definition at line 287 of file OHash.php.

& OHash::values  ) 
 

Retrieve hash values array.

Returns:
hashtable

Definition at line 190 of file OHash.php.

References ref().


Member Data Documentation

OHash::$_hash
 

Definition at line 43 of file OHash.php.


The documentation for this class was generated from the following file:
Generated on Tue Jun 29 23:40:51 2004 for Mediawiki by doxygen 1.3.7