首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Judy (class)

Introduction

(PECL judy >= 0.1.1)

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 :

  • Judy::BITSET
  • Judy::INT_TO_INT
  • Judy::INT_TO_MIXED
  • Judy::STRING_TO_INT
  • Judy::STRING_TO_MIXED

Example #1 Judy array example

代码语言:javascript
复制
<?php
????$judy?=?new?Judy(Judy::INT_TO_MIXED);
????$judy[1]?=?"one";
????$judy[2]?=?array('a',?'b',?'c');
????$judy[3]?=?new?Judy(Judy::BITSET);
?>

Class synopsis

Judy implements ArrayAccess , Iterator {

/* Constants */

const integer BITSET = 1 ;

const integer INT_TO_INT = 2 ;

const integer INT_TO_MIXED = 3 ;

const integer STRING_TO_INT = 4 ;

const integer STRING_TO_MIXED = 5 ;

/* Methods */

代码语言:javascript
复制
public int byCount ( int $nth_index )
代码语言:javascript
复制
public __construct ( int $judy_type )
代码语言:javascript
复制
public int count ([ int $index_start = 0 [, int $index_end = -1 ]] )
代码语言:javascript
复制
public void __destruct ( void )
代码语言:javascript
复制
public mixed first ([ mixed $index ] )
代码语言:javascript
复制
public int firstEmpty ([ mixed $index = 0 ] )
代码语言:javascript
复制
public int free ( void )
代码语言:javascript
复制
public int getType ( void )
代码语言:javascript
复制
public void last ([ string $index ] )
代码语言:javascript
复制
public int lastEmpty ([ int $index = -1 ] )
代码语言:javascript
复制
public int memoryUsage ( void )
代码语言:javascript
复制
public mixed next ( mixed $index )
代码语言:javascript
复制
public int nextEmpty ( int $index )
代码语言:javascript
复制
public bool offsetExists ( mixed $offset )
代码语言:javascript
复制
public mixed offsetGet ( mixed $offset )
代码语言:javascript
复制
public bool offsetSet ( mixed $offset , mixed $value )
代码语言:javascript
复制
public bool offsetUnset ( mixed $offset )
代码语言:javascript
复制
public mixed prev ( mixed $index )
代码语言:javascript
复制
public int prevEmpty ( mixed $index )
代码语言:javascript
复制
public void size ( void )

}

Predefined Constants

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.

Table of Contents

  • 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::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::byCount →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com