>> YANA 4 PHP Framework >> Docs For Class Hashtable

Class Hashtable

Description

«utility» Hashtable

This is a static utility class to implement certain operations on hashtables (associative arrays).

Example for usage of the $key parameter:

 Array {
     ID1 => Array {
         ID2 => 'value'
     }
 }
To get the string 'value' from the hashtable above use $key = 'ID1.ID2'

The wildcard '*' may be used to refer to the hashtable as a whole.

  • access: public

Located in /includes/class_hashtable.php

Utility
   |
   --Hashtable
Method Summary
  • boolean exists ( &$hash, string $key, array $hash)
  • mixed &get ( &$hash, string $key, array $hash)
  • boolean remove ( &$hash, string $key, array $hash)
  • boolean set ( &$hash, string $key, mixed $value, array $hash)
  • boolean setByReference ( &$hash, string $key,  &$value, array $hash, mixed $value)
  • boolean setType ( &$hash, string $key, string $type, array $hash)

Methods

check if an element exists
boolean exists (
 &$hash, string $key, array $hash
)
List of parameters:
Name Type Description
$hash array
$key string
&$hash
Description:

Returns bool(false) if the element identified by $key can not be found in the given hashtable or it is NULL. Returns bool(true) otherwise.

  • access: public
retrieve a value
mixed &get (
 &$hash, string $key, array $hash
)
List of parameters:
Name Type Description
$hash array
$key string
&$hash
Description:

Finds the value identified by $key and returns it. If the value is not found NULL is returned.

  • access: public
remove an element
boolean remove (
 &$hash, string $key, array $hash
)
List of parameters:
Name Type Description
$hash array
$key string
&$hash
Description:

Unsets the element identified by $key in the hashtable. Returns bool(false) if the element does not exist or the key is invalid. Returns bool(true) otherwise.

  • access: public
set an element to a value
boolean set (
 &$hash, string $key, mixed $value, array $hash
)
List of parameters:
Name Type Description
$hash array
$key string
$value mixed
&$hash
Description:

Sets the element identified by $key to $value. If the value does not exist it gets inserted. If a previous value existed the value gets updated.

This function returns bool(false) if $key = '*' and $value is not an array - which is: trying overwrite the complete hashtable with a non-array value. It returns bool(true) otherwise.

  • see: Hashtable::setByReference
  • name: Hashtable::set
  • access: public
set an element by Reference
boolean setByReference (
 &$hash, string $key,  &$value, array $hash, mixed $value
)
List of parameters:
Name Type Description
$hash array
$key string
$value mixed
&$hash
&$value
Description:

Sets the element identified by $key to $value by passing it's reference. If the value does not exist it gets inserted. If a previous value existed the value gets updated.

This function returns bool(false) if $key = '*' and $value is not an array - which is: trying overwrite the complete hashtable with a non-array value. It returns bool(true) otherwise.

  • since: 2.8.5
  • see: Hashtable::set
  • name: Hashtable::setByReference
  • access: public
set the data type of an element
boolean setType (
 &$hash, string $key, string $type, array $hash
)
List of parameters:
Name Type Description
$hash array
$key string
$type string
&$hash
Description:

Set the data type of the element identified by $key to $type.

Returns bool(false) if the element is NULL or does not exist, or the $type parameter is invalid. Returns bool(true) otherwise.

  • access: public
inherited from base classes

Inherited From Utility

Documentation generated on Wed, 22 Nov 2006 20:19:07 +0100 by phpDocumentor 1.3.1

yana author: Thomas MeyerHomepage: www.all-community.de/pub