PHP Judy 陣列 - Judy 類()



Judy 類可以實現 ArrayAccess 介面和 Iterator 介面。一旦例項化此類,我們就可以像 PHP 陣列一樣訪問它。

PHP Judy 物件(或 Judy 陣列)可以是以下型別之一 -

預定義常量

  • Judy::BITSET - 將 Judy 陣列定義為位集,鍵為整數,值為布林值。
  • Judy::INT_TO_INT - 定義鍵/值為整數且僅為整數的 Judy 陣列。
  • Judy::INT_TO_MIXED - 定義鍵為整數且值為任何型別的 Judy 陣列。
  • Judy::STRING_TO_INT - 定義鍵為字串且值為整數且僅為整數的 Judy 陣列。
  • Judy::STRING_TO_MIXED - 定義鍵為字串且值為任何型別的 Judy 陣列。

示例

<?php
   $judy = new Judy(Judy::INT_TO_INT);
   $judy[5] = 2;
   $judy[3] = 1;
   $judy[6] = 3;

   echo $judy->offSetGet($judy->last(4));
?>

類概要

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 */
   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 )
}
php_function_reference.htm
廣告