Book/judy-Phpdoc专题
Judy Arrays
目录
- 简介
- 安装/配置
- Judy — The Judy class
- Judy::byCount — Locate the Nth index present in the Judy array
- Judy::__construct — Construct a new Judy object
- Judy::count — Count the number of elements in the Judy array
- Judy::__destruct — Destruct a Judy object
- Judy::first — Search for the first index in the Judy array
- Judy::firstEmpty — Search for the first absent index in the Judy array
- Judy::free — Free the entire Judy array
- Judy::getType — Return the type of the current Judy array
- Judy::last — Search for the last index in the Judy array
- Judy::lastEmpty — Search for the last absent index in the Judy array
- Judy::memoryUsage — Return the memory used by the Judy array
- Judy::next — Search for the next index in the Judy array
- Judy::nextEmpty — Search for the next absent index in the Judy array
- Judy::offsetExists — Whether a offset exists
- Judy::offsetGet — Offset to retrieve
- Judy::offsetSet — Offset to set
- Judy::offsetUnset — Offset to unset
- Judy::prev — Search for the previous index in the Judy array
- Judy::prevEmpty — Search for the previous absent index in the Judy array
- Judy::size — Return the size of the current Judy array
- Judy 函数
- judy_type — Return the type of a Judy array
- judy_version — Return or print the current PHP Judy version
简介
The Judy class implements the ArrayAccess interface and the Iterator interface. This class, once instantiated, can be accessed like a PHP array.
A PHP Judy object (or Judy Array) can be one of the following type :
示例 #1 Judy array example
<?php
$judy = new Judy(Judy::INT_TO_MIXED);
$judy[1] = "one";
$judy[2] = array('a', 'b', 'c');
$judy[3] = new Judy(Judy::BITSET);
?>
类摘要
Judy
class Judy <span class="oointerface">implements <span class="interfacename">ArrayAccess <span class="oointerface">, Iterator {
/* Constants */
const int
Judy::BITSET = 1 ;
const int
Judy::INT_TO_INT = 2 ;
const int
Judy::INT_TO_MIXED = 3 ;
const int
Judy::STRING_TO_INT = 4 ;
const int
Judy::STRING_TO_MIXED = 5 ;
/* 方法 */
public int <span
class="methodname">byCount ( <span
class="type">int $nth_index )
public <span
class="methodname">__construct ( <span
class="methodparam">int $judy_type )
public int <span
class="methodname">count ([ <span
class="type">int $index_start =
0 [, <span
class="type">int $index_end =
-1 ]] )
public void __destruct ( <span class="methodparam">void )
public mixed
first ([ <span
class="methodparam">mixed $index ] )
public int <span
class="methodname">firstEmpty ([ <span
class="type">mixed $index =
0 ] )
public int <span class="methodname">free ( void )
public int <span class="methodname">getType ( <span class="methodparam">void )
public void
last ([ <span
class="type">string $index ] )
public int <span
class="methodname">lastEmpty ([ <span
class="type">int $index =
-1 ] )
public int <span class="methodname">memoryUsage ( <span class="methodparam">void )
public mixed
next ( <span
class="type">mixed $index )
public int <span
class="methodname">nextEmpty ( <span
class="type">int $index )
public bool
offsetExists ( <span
class="methodparam">mixed $offset )
public mixed
offsetGet ( <span
class="methodparam">mixed $offset )
public bool
offsetSet ( <span
class="methodparam">mixed $offset ,
mixed
$value )
public bool
offsetUnset ( <span
class="methodparam">mixed $offset )
public mixed
prev ( <span
class="type">mixed $index )
public int <span
class="methodname">prevEmpty ( <span
class="type">mixed $index )
public void size ( <span class="methodparam">void )
}
预定义常量
Judy::BITSET
Define the Judy Array as a Bitset with keys as Integer and Values as a
Boolean
Judy::INT_TO_INT
Define the Judy Array with key/values as Integer, and Integer only.
Judy::INT_TO_MIXED
Define the Judy Array with keys as Integer and Values of any type.
Judy::STRING_TO_INT
Define the Judy Array with keys as a String and Values as Integer, and
Integer only.
Judy::STRING_TO_MIXED
Define the Judy Array with keys as a String and Values of any type.
Judy::byCount
Locate the Nth index present in the Judy array
说明
public int <span
class="methodname">Judy::byCount ( <span
class="methodparam">int $nth_index )
Locate the Nth index present in the Judy array.
参数
nth_index
Nth index to return. If nth_index equal 1, then it will return the
first index in the array.
返回值
Return the index at the given Nth position.
Judy::__construct
Construct a new Judy object
说明
public <span
class="methodname">Judy::__construct ( <span
class="methodparam">int $judy_type )
Construct a new Judy object. A Judy object can be accessed like a PHP Array.
参数
judy_type
The Judy type to be used.
返回值
Return the new Judy instance.
Judy::count
Count the number of elements in the Judy array
说明
public int <span
class="methodname">Judy::count ([ <span
class="methodparam">int $index_start<span
class="initializer"> = 0 [, <span
class="methodparam">int $index_end<span
class="initializer"> = -1 ]] )
Count the number of elements in the Judy array.
参数
index_start
Start counting from the given index. Default is first index.
index_end
Stop counting when reaching this index. Default is last index.
返回值
Return the number of elements.
Judy::__destruct
Destruct a Judy object
说明
public void Judy::__destruct ( <span class="methodparam">void )
Destruct a Judy object.
参数
此函数没有参数。
返回值
Judy::first
Search for the first index in the Judy array
说明
public mixed
Judy::first ([ <span
class="methodparam">mixed $index ] )
Search (inclusive) for the first index present that is equal to or greater than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::firstEmpty
Search for the first absent index in the <span class="classname">Judy array
说明
public int <span
class="methodname">Judy::firstEmpty ([ <span
class="methodparam">mixed $index<span
class="initializer"> = 0 ] )
Search (inclusive) for the first absent index that is equal to or greater than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::free
Free the entire Judy array
说明
public int <span class="methodname">Judy::free ( <span class="methodparam">void )
Free the entire Judy array.
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
Judy::getType
Return the type of the current Judy array
说明
public int <span class="methodname">Judy::getType ( <span class="methodparam">void )
Return an integer corresponding to the Judy type of the current object.
参数
此函数没有参数。
返回值
Return an integer corresponding to a Judy type.
Judy::last
Search for the last index in the Judy array
说明
public void
Judy::last ([ <span
class="methodparam">string $index ]
)
Search (inclusive) for the last index present that is equal to or less than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::lastEmpty
Search for the last absent index in the <span class="classname">Judy array
说明
public int <span
class="methodname">Judy::lastEmpty ([ <span
class="methodparam">int $index<span
class="initializer"> = -1 ] )
Search (inclusive) for the last absent index that is equal to or less than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::memoryUsage
Return the memory used by the Judy array
说明
public int <span class="methodname">Judy::memoryUsage ( <span class="methodparam">void )
Return the memory used by the Judy array.
参数
此函数没有参数。
返回值
Return the memory used in bytes.
Judy::next
Search for the next index in the Judy array
说明
public mixed
Judy::next ( <span
class="methodparam">mixed $index )
Search (exclusive) for the next index present that is greater than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::nextEmpty
Search for the next absent index in the <span class="classname">Judy array
说明
public int <span
class="methodname">Judy::nextEmpty ( <span
class="methodparam">int $index )
Search (exclusive) for the next absent index that is greater than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::offsetExists
Whether a offset exists
说明
public bool
Judy::offsetExists ( <span
class="methodparam">mixed $offset )
Whether or not an offset exists.
参数
offset
An offset to check for.
返回值
Returns true on success or false on failure.
Judy::offsetGet
Offset to retrieve
说明
public mixed
Judy::offsetGet ( <span
class="methodparam">mixed $offset )
Returns the value at specified offset.
参数
offset
The offset to retrieve.
返回值
Can return all value types.
Judy::offsetSet
Offset to set
说明
public bool
Judy::offsetSet ( <span
class="methodparam">mixed $offset ,
mixed
$value )
Assigns a value to the specified offset.
参数
offset
The offset to assign the value to.
value
The value to set.
返回值
No value is returned.
Judy::offsetUnset
Offset to unset
说明
public bool
Judy::offsetUnset ( <span
class="methodparam">mixed $offset )
Unsets an offset.
参数
offset
The offset to unset.
返回值
No value is returned.
Judy::prev
Search for the previous index in the Judy array
说明
public mixed
Judy::prev ( <span
class="methodparam">mixed $index )
Search (exclusive) for the previous index present that is less than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::prevEmpty
Search for the previous absent index in the <span class="classname">Judy array
说明
public int <span
class="methodname">Judy::prevEmpty ( <span
class="methodparam">mixed $index )
Search (exclusive) for the previous index absent that is less than the passed Index.
参数
index
The index can be an integer or a string corresponding to the index where
to start the search.
返回值
Return the corresponding index in the array.
Judy::size
Return the size of the current Judy array
说明
public void Judy::size ( <span class="methodparam">void )
此方法是该方法的别名: Judy::count.
Warning
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
Return an integer.