Judy Arrays

目录

简介

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 implements ArrayAccess , Iterator {

/* Constants */

const integer Judy::BITSET = 1 ;

const integer Judy::INT_TO_INT = 2 ;

const integer Judy::INT_TO_MIXED = 3 ;

const integer Judy::STRING_TO_INT = 4 ;

const integer Judy::STRING_TO_MIXED = 5 ;

/* 方法 */

public int byCount ( int $nth_index )

public __construct ( int $judy_type )

public int count ([ int $index_start = 0 [, int $index_end = -1 ]] )

public void __destruct ( void )

public mixed first ([ mixed $index ] )

public int firstEmpty ([ mixed $index = 0 ] )

public int free ( void )

public int getType ( void )

public void last ([ string $index ] )

public int lastEmpty ([ int $index = -1 ] )

public int memoryUsage ( void )

public mixed next ( mixed $index )

public int nextEmpty ( int $index )

public bool offsetExists ( mixed $offset )

public mixed offsetGet ( mixed $offset )

public bool offsetSet ( mixed $offset , mixed $value )

public bool offsetUnset ( mixed $offset )

public mixed prev ( mixed $index )

public int prevEmpty ( mixed $index )

public void size ( 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 Judy::byCount ( 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 Judy::__construct ( 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 Judy::count ([ int $index_start = 0 [, int $index_end = -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 ( void )

Destruct a Judy object.

参数

此函数没有参数。

返回值

Judy::first

Search for the first index in the Judy array

说明

public mixed Judy::first ([ 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 Judy array

说明

public int Judy::firstEmpty ([ mixed $index = 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 Judy::free ( void )

Free the entire Judy array.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Judy::getType

Return the type of the current Judy array

说明

public int Judy::getType ( 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 ([ 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 Judy array

说明

public int Judy::lastEmpty ([ int $index = -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 Judy::memoryUsage ( 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 ( 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 Judy array

说明

public int Judy::nextEmpty ( 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 ( 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 ( 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 ( 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 ( 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 ( 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 Judy array

说明

public int Judy::prevEmpty ( 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 ( void )

此方法是该方法的别名: Judy::count.

Warning

本函数还未编写文档,仅有参数列表。

参数

此函数没有参数。

返回值

Return an integer.