Class Hashtable (namespace Nette\Collections)


Provides the base class for a generic collection of keys and values.

ArrayObject
   |
   --Collection
      |
      --Hashtable

Implements interfaces:

Direct Known Sub-classes:

Copyright: Copyright (c) 2004, 2010 David Grudl
Located: in /Collections/Hashtable.php (line 32)
Public Method Summary
bool
add (mixed $key, mixed $item)
Inserts the specified element to the map.
void
append ($item)
Append is not supported.
mixed
get (string $key, [mixed $default = NULL])
Returns variable or $default if there is no element.
void
getKeys ()
Returns a array of the keys contained in this map.
void
import (array|\Traversable $arr)
Import from array or any traversable object.
bool
offsetExists (string $key)
Exists item? (\ArrayAccess implementation).
mixed
offsetGet (string $key)
Returns item (\ArrayAccess implementation).
void
offsetSet (string $key, object $item)
Inserts (replaces) item (\ArrayAccess implementation).
void
offsetUnset (string $key)
Removes the element at the specified position in this list.
mixed
search (mixed $item)
Returns the key of the first occurrence of the specified element,.
void
throwKeyNotFound ([$val = TRUE])
Do throw KeyNotFoundException?
Methods Inherited From Collection
__construct(), append(), beforeAdd(), clear(), contains(), exchangeArray(), freeze(), getItemType(), getIterator(), getReflection(), import(), isFrozen(), isReadOnly(), remove(), search(), setArray(), setReadOnly(), updating(), __call(), __callStatic(), __clone(), __get(), __isset(), __set(), __unset()

Method Details

line 46

add

public bool add (mixed $key, mixed $item)

Inserts the specified element to the map.

Implementation of:

Input
mixed $key
mixed $item
Output
bool  
Throws
throws InvalidArgumentException, \InvalidStateException

line 67

append

public void append ($item)

Append is not supported.

Implementation of:

Input
$item
Output
void  

line 132

get

public mixed get (string $key, [mixed $default = NULL])

Returns variable or $default if there is no element.

Input
string $key key
mixed $default default value
Output
mixed  
Throws
throws InvalidArgumentException

line 78

getKeys

public void getKeys ()

Returns a array of the keys contained in this map.

return array

Implementation of:

Output
void  

line 104

import

public void import (array|\Traversable $arr)

Import from array or any traversable object.

Overridden in child classes as:

Input
array|\Traversable $arr
Output
void  
Throws
throws InvalidArgumentException

line 213

offsetExists

public bool offsetExists (string $key)

Exists item? (\ArrayAccess implementation).

Input
string $key key
Output
bool  
Throws
throws InvalidArgumentException

line 188

offsetGet

public mixed offsetGet (string $key)

Returns item (\ArrayAccess implementation).

Input
string $key key
Output
mixed  
Throws
throws KeyNotFoundException, \InvalidArgumentException

line 170

offsetSet

public void offsetSet (string $key, object $item)

Inserts (replaces) item (\ArrayAccess implementation).

Input
string $key key
object $item
Output
void  
Throws
throws NotSupportedException, \InvalidArgumentException

line 230

offsetUnset

public void offsetUnset (string $key)

Removes the element at the specified position in this list.

Input
string $key key
Output
void  
Throws
throws NotSupportedException, \InvalidArgumentException

line 91

search

public mixed search (mixed $item)

Returns the key of the first occurrence of the specified element,.

or FALSE if this map does not contain this element.

Implementation of:

Input
mixed $item
Output
mixed  

line 152

throwKeyNotFound

public void throwKeyNotFound ([$val = TRUE])

Do throw KeyNotFoundException?

Input
$val
Output
void