From 5fe42e0290b0beb738ac56a894c798c8f90b5d4c Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Thu, 28 Jul 2011 17:20:50 +0000 Subject: [PATCH] - Added the QuickHash extension's documentation. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@313895 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/quickhash/book.xml | 46 +++++ reference/quickhash/constants.xml | 29 +++ .../quickhash/entities.quickhashinthash.xml | 12 ++ .../quickhash/entities.quickhashintset.xml | 9 + .../entities.quickhashintstringhash.xml | 12 ++ .../entities.quickhashstringinthash.xml | 12 ++ reference/quickhash/examples.xml | 150 +++++++++++++++ reference/quickhash/quickhashinthash.xml | 160 ++++++++++++++++ reference/quickhash/quickhashinthash/add.xml | 138 +++++++++++++ .../quickhash/quickhashinthash/construct.xml | 108 +++++++++++ .../quickhash/quickhashinthash/delete.xml | 102 ++++++++++ .../quickhash/quickhashinthash/exists.xml | 112 +++++++++++ reference/quickhash/quickhashinthash/get.xml | 99 ++++++++++ .../quickhash/quickhashinthash/getsize.xml | 92 +++++++++ .../quickhashinthash/loadfromfile.xml | 162 ++++++++++++++++ .../quickhashinthash/loadfromstring.xml | 130 +++++++++++++ .../quickhash/quickhashinthash/savetofile.xml | 89 +++++++++ .../quickhashinthash/savetostring.xml | 74 +++++++ reference/quickhash/quickhashinthash/set.xml | 118 ++++++++++++ .../quickhash/quickhashinthash/update.xml | 107 +++++++++++ reference/quickhash/quickhashintset.xml | 158 +++++++++++++++ reference/quickhash/quickhashintset/add.xml | 112 +++++++++++ .../quickhash/quickhashintset/construct.xml | 108 +++++++++++ .../quickhash/quickhashintset/delete.xml | 97 ++++++++++ .../quickhash/quickhashintset/exists.xml | 112 +++++++++++ .../quickhash/quickhashintset/getsize.xml | 92 +++++++++ .../quickhashintset/loadfromfile.xml | 128 +++++++++++++ .../quickhashintset/loadfromstring.xml | 128 +++++++++++++ .../quickhash/quickhashintset/savetofile.xml | 89 +++++++++ .../quickhashintset/savetostring.xml | 74 +++++++ .../quickhash/quickhashintstringhash.xml | 160 ++++++++++++++++ .../quickhash/quickhashintstringhash/add.xml | 130 +++++++++++++ .../quickhashintstringhash/construct.xml | 108 +++++++++++ .../quickhashintstringhash/delete.xml | 102 ++++++++++ .../quickhashintstringhash/exists.xml | 67 +++++++ .../quickhash/quickhashintstringhash/get.xml | 99 ++++++++++ .../quickhashintstringhash/getsize.xml | 76 ++++++++ .../quickhashintstringhash/loadfromfile.xml | 170 ++++++++++++++++ .../quickhashintstringhash/loadfromstring.xml | 127 ++++++++++++ .../quickhashintstringhash/savetofile.xml | 89 +++++++++ .../quickhashintstringhash/savetostring.xml | 74 +++++++ .../quickhash/quickhashintstringhash/set.xml | 120 ++++++++++++ .../quickhashintstringhash/update.xml | 117 +++++++++++ .../quickhash/quickhashstringinthash.xml | 118 ++++++++++++ .../quickhash/quickhashstringinthash/add.xml | 135 +++++++++++++ .../quickhashstringinthash/construct.xml | 100 ++++++++++ .../quickhashstringinthash/delete.xml | 106 ++++++++++ .../quickhashstringinthash/exists.xml | 67 +++++++ .../quickhash/quickhashstringinthash/get.xml | 94 +++++++++ .../quickhashstringinthash/getsize.xml | 92 +++++++++ .../quickhashstringinthash/loadfromfile.xml | 181 ++++++++++++++++++ .../quickhashstringinthash/loadfromstring.xml | 126 ++++++++++++ .../quickhashstringinthash/savetofile.xml | 87 +++++++++ .../quickhashstringinthash/savetostring.xml | 71 +++++++ .../quickhash/quickhashstringinthash/set.xml | 120 ++++++++++++ .../quickhashstringinthash/update.xml | 119 ++++++++++++ reference/quickhash/reference.xml | 31 +++ reference/quickhash/setup.xml | 49 +++++ reference/quickhash/versions.xml | 63 ++++++ 59 files changed, 5857 insertions(+) create mode 100644 reference/quickhash/book.xml create mode 100644 reference/quickhash/constants.xml create mode 100644 reference/quickhash/entities.quickhashinthash.xml create mode 100644 reference/quickhash/entities.quickhashintset.xml create mode 100644 reference/quickhash/entities.quickhashintstringhash.xml create mode 100644 reference/quickhash/entities.quickhashstringinthash.xml create mode 100644 reference/quickhash/examples.xml create mode 100644 reference/quickhash/quickhashinthash.xml create mode 100644 reference/quickhash/quickhashinthash/add.xml create mode 100644 reference/quickhash/quickhashinthash/construct.xml create mode 100644 reference/quickhash/quickhashinthash/delete.xml create mode 100644 reference/quickhash/quickhashinthash/exists.xml create mode 100644 reference/quickhash/quickhashinthash/get.xml create mode 100644 reference/quickhash/quickhashinthash/getsize.xml create mode 100644 reference/quickhash/quickhashinthash/loadfromfile.xml create mode 100644 reference/quickhash/quickhashinthash/loadfromstring.xml create mode 100644 reference/quickhash/quickhashinthash/savetofile.xml create mode 100644 reference/quickhash/quickhashinthash/savetostring.xml create mode 100644 reference/quickhash/quickhashinthash/set.xml create mode 100644 reference/quickhash/quickhashinthash/update.xml create mode 100644 reference/quickhash/quickhashintset.xml create mode 100644 reference/quickhash/quickhashintset/add.xml create mode 100644 reference/quickhash/quickhashintset/construct.xml create mode 100644 reference/quickhash/quickhashintset/delete.xml create mode 100644 reference/quickhash/quickhashintset/exists.xml create mode 100644 reference/quickhash/quickhashintset/getsize.xml create mode 100644 reference/quickhash/quickhashintset/loadfromfile.xml create mode 100644 reference/quickhash/quickhashintset/loadfromstring.xml create mode 100644 reference/quickhash/quickhashintset/savetofile.xml create mode 100644 reference/quickhash/quickhashintset/savetostring.xml create mode 100644 reference/quickhash/quickhashintstringhash.xml create mode 100644 reference/quickhash/quickhashintstringhash/add.xml create mode 100644 reference/quickhash/quickhashintstringhash/construct.xml create mode 100644 reference/quickhash/quickhashintstringhash/delete.xml create mode 100644 reference/quickhash/quickhashintstringhash/exists.xml create mode 100644 reference/quickhash/quickhashintstringhash/get.xml create mode 100644 reference/quickhash/quickhashintstringhash/getsize.xml create mode 100644 reference/quickhash/quickhashintstringhash/loadfromfile.xml create mode 100644 reference/quickhash/quickhashintstringhash/loadfromstring.xml create mode 100644 reference/quickhash/quickhashintstringhash/savetofile.xml create mode 100644 reference/quickhash/quickhashintstringhash/savetostring.xml create mode 100644 reference/quickhash/quickhashintstringhash/set.xml create mode 100644 reference/quickhash/quickhashintstringhash/update.xml create mode 100644 reference/quickhash/quickhashstringinthash.xml create mode 100644 reference/quickhash/quickhashstringinthash/add.xml create mode 100644 reference/quickhash/quickhashstringinthash/construct.xml create mode 100644 reference/quickhash/quickhashstringinthash/delete.xml create mode 100644 reference/quickhash/quickhashstringinthash/exists.xml create mode 100644 reference/quickhash/quickhashstringinthash/get.xml create mode 100644 reference/quickhash/quickhashstringinthash/getsize.xml create mode 100644 reference/quickhash/quickhashstringinthash/loadfromfile.xml create mode 100644 reference/quickhash/quickhashstringinthash/loadfromstring.xml create mode 100644 reference/quickhash/quickhashstringinthash/savetofile.xml create mode 100644 reference/quickhash/quickhashstringinthash/savetostring.xml create mode 100644 reference/quickhash/quickhashstringinthash/set.xml create mode 100644 reference/quickhash/quickhashstringinthash/update.xml create mode 100644 reference/quickhash/reference.xml create mode 100644 reference/quickhash/setup.xml create mode 100644 reference/quickhash/versions.xml diff --git a/reference/quickhash/book.xml b/reference/quickhash/book.xml new file mode 100644 index 0000000000..cd45b691d2 --- /dev/null +++ b/reference/quickhash/book.xml @@ -0,0 +1,46 @@ + + + + + Quickhash + Quickhash + + + &reftitle.intro; + + The quickhash extension contains a set of specific strongly-typed classes + to deal with specific set and hash implementions. + + + + &reference.quickhash.setup; + &reference.quickhash.constants; + &reference.quickhash.examples; + + &reference.quickhash.quickhashintset; + &reference.quickhash.quickhashinthash; + &reference.quickhash.quickhashstringinthash; + &reference.quickhash.quickhashintstringhash; + + + + diff --git a/reference/quickhash/constants.xml b/reference/quickhash/constants.xml new file mode 100644 index 0000000000..fec1b2226e --- /dev/null +++ b/reference/quickhash/constants.xml @@ -0,0 +1,29 @@ + + + + + &reftitle.constants; + &no.constants; + + + + diff --git a/reference/quickhash/entities.quickhashinthash.xml b/reference/quickhash/entities.quickhashinthash.xml new file mode 100644 index 0000000000..ea2b5ff1b7 --- /dev/null +++ b/reference/quickhash/entities.quickhashinthash.xml @@ -0,0 +1,12 @@ +&reference.quickhash.quickhashinthash.add; +&reference.quickhash.quickhashinthash.construct; +&reference.quickhash.quickhashinthash.delete; +&reference.quickhash.quickhashinthash.exists; +&reference.quickhash.quickhashinthash.get; +&reference.quickhash.quickhashinthash.getsize; +&reference.quickhash.quickhashinthash.loadfromfile; +&reference.quickhash.quickhashinthash.loadfromstring; +&reference.quickhash.quickhashinthash.savetofile; +&reference.quickhash.quickhashinthash.savetostring; +&reference.quickhash.quickhashinthash.set; +&reference.quickhash.quickhashinthash.update; diff --git a/reference/quickhash/entities.quickhashintset.xml b/reference/quickhash/entities.quickhashintset.xml new file mode 100644 index 0000000000..3e7d269ed3 --- /dev/null +++ b/reference/quickhash/entities.quickhashintset.xml @@ -0,0 +1,9 @@ +&reference.quickhash.quickhashintset.add; +&reference.quickhash.quickhashintset.construct; +&reference.quickhash.quickhashintset.delete; +&reference.quickhash.quickhashintset.exists; +&reference.quickhash.quickhashintset.getsize; +&reference.quickhash.quickhashintset.loadfromfile; +&reference.quickhash.quickhashintset.loadfromstring; +&reference.quickhash.quickhashintset.savetofile; +&reference.quickhash.quickhashintset.savetostring; diff --git a/reference/quickhash/entities.quickhashintstringhash.xml b/reference/quickhash/entities.quickhashintstringhash.xml new file mode 100644 index 0000000000..5e34483281 --- /dev/null +++ b/reference/quickhash/entities.quickhashintstringhash.xml @@ -0,0 +1,12 @@ +&reference.quickhash.quickhashintstringhash.add; +&reference.quickhash.quickhashintstringhash.construct; +&reference.quickhash.quickhashintstringhash.delete; +&reference.quickhash.quickhashintstringhash.exists; +&reference.quickhash.quickhashintstringhash.get; +&reference.quickhash.quickhashintstringhash.getsize; +&reference.quickhash.quickhashintstringhash.loadfromfile; +&reference.quickhash.quickhashintstringhash.loadfromstring; +&reference.quickhash.quickhashintstringhash.savetofile; +&reference.quickhash.quickhashintstringhash.savetostring; +&reference.quickhash.quickhashintstringhash.set; +&reference.quickhash.quickhashintstringhash.update; diff --git a/reference/quickhash/entities.quickhashstringinthash.xml b/reference/quickhash/entities.quickhashstringinthash.xml new file mode 100644 index 0000000000..0153888742 --- /dev/null +++ b/reference/quickhash/entities.quickhashstringinthash.xml @@ -0,0 +1,12 @@ +&reference.quickhash.quickhashstringinthash.add; +&reference.quickhash.quickhashstringinthash.construct; +&reference.quickhash.quickhashstringinthash.delete; +&reference.quickhash.quickhashstringinthash.exists; +&reference.quickhash.quickhashstringinthash.get; +&reference.quickhash.quickhashstringinthash.getsize; +&reference.quickhash.quickhashstringinthash.loadfromfile; +&reference.quickhash.quickhashstringinthash.loadfromstring; +&reference.quickhash.quickhashstringinthash.savetofile; +&reference.quickhash.quickhashstringinthash.savetostring; +&reference.quickhash.quickhashstringinthash.set; +&reference.quickhash.quickhashstringinthash.update; diff --git a/reference/quickhash/examples.xml b/reference/quickhash/examples.xml new file mode 100644 index 0000000000..041695563c --- /dev/null +++ b/reference/quickhash/examples.xml @@ -0,0 +1,150 @@ + + + + + &reftitle.examples; + + Quickhash Example + +add( 1 ); +$set->add( 3 ); + +var_dump( $set->exists( 3 ) ); +var_dump( $set->exists( 4 ) ); + +$set->saveToFile( "/tmp/test-set.set" ); + +$newSet = QuickHashIntSet::loadFromFile( + "/tmp/test-set.set" +); + +var_dump( $newSet->exists( 3 ) ); +var_dump( $newSet->exists( 4 ) ); +?> +]]> + + &example.outputs.similar; + + + + + + Quickhash ArrayAccess Example + + +]]> + + &example.outputs.similar; + + + + + + Quickhash Iterator Example + + $value ) +{ + echo $key, ' => ', $value, "\n"; +} +?> +]]> + + &example.outputs.similar; + + -4234 +4 => 712314 +1 => 145926 +2 => 1415926 +3 => 72 +]]> + + + + Quickhash String Values Example + +add( 2, "one more" );1415926; + +foreach( $hash as $key => $value ) +{ + echo $key, ' => ', $value, "\n"; +} +?> +]]> + + &example.outputs.similar; + + one million four hundred fifteen thousand nine hundred twenty six +2 => one more +]]> + + + + + + diff --git a/reference/quickhash/quickhashinthash.xml b/reference/quickhash/quickhashinthash.xml new file mode 100644 index 0000000000..b60dc6a4b9 --- /dev/null +++ b/reference/quickhash/quickhashinthash.xml @@ -0,0 +1,160 @@ + + + + + + The QuickHashIntHash class + QuickHashIntHash + + + + +
+ &reftitle.intro; + + This class wraps around a hash containing integer numbers, where the + values are also integer numbers. Hashes are also available as + implementation of the ArrayAccess interface. + + + Hashes can also be iterated over with foreach as the Iterator interface is + implemented as well. The order of which elements are returned in is not + guaranteed. + +
+ + +
+ &reftitle.classsynopsis; + + + + QuickHashIntHash + + + + + QuickHashIntHash + + + + Constants + + const + integer + QuickHashIntHash::CHECK_FOR_DUPES + 1 + + + const + integer + QuickHashIntHash::DO_NOT_USE_ZEND_ALLOC + 2 + + + const + integer + QuickHashIntHash::HASHER_NO_HASH + 256 + + + const + integer + QuickHashIntHash::HASHER_JENKINS1 + 512 + + + const + integer + QuickHashIntHash::HASHER_JENKINS2 + 1024 + + + Methods + + + + +
+ + +
+ &reftitle.constants; +
+ QuickHashIntHash Node Types + + + + QuickHashIntHash::CHECK_FOR_DUPES + + If enabled, adding duplicate elements to a set (through either add() or + loadFromFile()) will result in those elements to be dropped from the + set. This will take up extra time, so only used when it is required. + + + + + QuickHashIntHash::DO_NOT_USE_ZEND_ALLOC + + Disables the use of PHP's internal memory manager for internal + set structures. With this option enabled, internal allocations will not + count towards the memory_limit settings. + + + + + QuickHashIntHash::HASHER_NO_HASH + + Selects to not use a hashing function, but merely use a modulo to + find the bucket list index. This is not faster than normal hashing, and + gives more collisions. + + + + + QuickHashIntHash::HASHER_JENKINS1 + + This is the default hashing function to turn the integer hashes + into bucket list indexes. + + + + + QuickHashIntHash::HASHER_JENKINS2 + + Selects a variant hashing algorithm. + + + + +
+
+ + + +
+ + &reference.quickhash.entities.quickhashinthash; + +
+ + diff --git a/reference/quickhash/quickhashinthash/add.xml b/reference/quickhash/quickhashinthash/add.xml new file mode 100644 index 0000000000..4f45c3d968 --- /dev/null +++ b/reference/quickhash/quickhashinthash/add.xml @@ -0,0 +1,138 @@ + + + + + + QuickHashIntHash::add + This method adds a new entry to the hash. + + + + &reftitle.description; + + public booleanQuickHashIntHash::add + integerkey + integervalue + + + This method adds a new entry to the hash, and returns whether the entry was + added. Entries are by default always added unless + QuickHashIntHash::CHECK_FOR_DUPES has been passed when the hash was created. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + value + + + The optional value of the entry to add. If no value is specified, + 1 will be used. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was added, and &false; if the entry was not added. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::add</function> example + +exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, 22 ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, 12 ) ); + +echo "\nwith dupe checking\n"; +$hash = new QuickHashIntHash( 1024, QuickHashIntHash::CHECK_FOR_DUPES ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, 78 ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, 9 ) ); + +echo "\ndefault value\n"; +var_dump( $hash->add( 5 ) ); +var_dump( $hash->get( 5 ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/construct.xml b/reference/quickhash/quickhashinthash/construct.xml new file mode 100644 index 0000000000..f77bb95b96 --- /dev/null +++ b/reference/quickhash/quickhashinthash/construct.xml @@ -0,0 +1,108 @@ + + + + + + QuickHashIntHash::__construct + Creates a new QuickHashIntHash object + + + + &reftitle.description; + + QuickHashIntHash::__construct + integersize + integeroptions + + + This constructor creates a new QuickHashIntHash. The size is the amount of + bucket lists to create. The more lists there are, the less collisions you + will have. Options are also supported. + + + + + &reftitle.parameters; + + + + size + + + The amount of bucket lists to configure. The number you pass in will be + automatically rounded up to the next power of two. It is also + automatically limited from 64 to 4194304. + + + + + options + + + The options that you can pass in are: QuickHashIntHash::CHECK_FOR_DUPES, + which makes sure no duplicate entries are added to the hash; + QuickHashIntHash::DO_NOT_USE_ZEND_ALLOC to not use PHP's internal memory + manager as well as one of QuickHashIntHash::HASHER_NO_HASH, + QuickHashIntHash::HASHER_JENKINS1 or QuickHashIntHash::HASHER_JENKINS2. + These last three configure which hashing algorithm to use. All options + can be combined using bitmasks. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntHash object. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::__construct</function> example + + +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/delete.xml b/reference/quickhash/quickhashinthash/delete.xml new file mode 100644 index 0000000000..784e57ff18 --- /dev/null +++ b/reference/quickhash/quickhashinthash/delete.xml @@ -0,0 +1,102 @@ + + + + + + QuickHashIntHash::delete + This method deletes am entry from the hash. + + + + &reftitle.description; + + public booleanQuickHashIntHash::delete + integerkey + + + This method deletes an entry from the hash, and returns whether the entry was + deleted or not. Associated memory structures will not be freed immediately, + but rather when the hash itself is freed. + + + Elements can not be deleted when the hash is used in an iterator. The + method will not throw an exception, but simply return &false; like would + happen with any other deletion failure. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to delete. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was deleted, and &false; if the entry was not deleted. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::delete</function> example + +exists( 4 ) ); +var_dump( $hash->add( 4, 5 ) ); +var_dump( $hash->delete( 4 ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->delete( 4 ) ); +?>]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/exists.xml b/reference/quickhash/quickhashinthash/exists.xml new file mode 100644 index 0000000000..5f581d9fdb --- /dev/null +++ b/reference/quickhash/quickhashinthash/exists.xml @@ -0,0 +1,112 @@ + + + + + + QuickHashIntHash::exists + This method checks whether a key is part of the hash + + + + &reftitle.description; + + public booleanQuickHashIntHash::exists + integerkey + + + This method checks whether an entry with the provided key exists in the + hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to check for whether it exists in the hash. + + + + + + + + + &reftitle.returnvalues; + + Returns &true; when the entry was found, or &false; when the entry is not + found. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::exists</function> example + +add( $key, 56 ); +} + +echo "Doing 1000 tests: ", microtime( true ), "\n"; +foreach( $testForEntries as $key ) +{ + $foundCount += $hash->exists( $key ); +} +echo "Done, $foundCount found: ", microtime( true ), "\n"; +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/get.xml b/reference/quickhash/quickhashinthash/get.xml new file mode 100644 index 0000000000..37d15389cb --- /dev/null +++ b/reference/quickhash/quickhashinthash/get.xml @@ -0,0 +1,99 @@ + + + + + + QuickHashIntHash::get + This method retrieves a value from the hash by its key. + + + + &reftitle.description; + + public integerQuickHashIntHash::get + integerkey + + + This method retrieves a value from the hash by its key. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + The value if the key exists, or &null; if the key wasn't part of the hash. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::get</function> example + +get( 1 ) ); + +var_dump( $hash->add( 2 ) ); +var_dump( $hash->get( 2 ) ); + +var_dump( $hash->add( 3, 5 ) ); +var_dump( $hash->get( 3 ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/getsize.xml b/reference/quickhash/quickhashinthash/getsize.xml new file mode 100644 index 0000000000..9457a6a674 --- /dev/null +++ b/reference/quickhash/quickhashinthash/getsize.xml @@ -0,0 +1,92 @@ + + + + + + QuickHashIntHash::getSize + Returns the number of elements in the hash + + + + &reftitle.description; + + public integerQuickHashIntHash::getSize + + + Returns the number of elements in the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + The number of elements in the hash. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::getSize</function> example + +add( 2 ) ); +var_dump( $hash->add( 3, 5 ) ); +var_dump( $hash->getSize() ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/loadfromfile.xml b/reference/quickhash/quickhashinthash/loadfromfile.xml new file mode 100644 index 0000000000..081d6b8a2a --- /dev/null +++ b/reference/quickhash/quickhashinthash/loadfromfile.xml @@ -0,0 +1,162 @@ + + + + + + QuickHashIntHash::loadFromFile + This factory method creates a hash from a file + + + + &reftitle.description; + + public static QuickHashIntHashQuickHashIntHash::loadFromFile + stringfilename + integeroptions + + + This factory method creates a new hash from a definition file on disk. The + file format consists of a signature 'QH\0x11\0', the number of elements as + a 32 bit signed integer in system Endianness, followed by 32 bit signed + integers packed together in the Endianness that the system that the code + runs on uses. For each hash element there are two 32 bit signed integers + stored. The first of each element is the key, and the second is the value + belonging to the key. An example could be: + + + + QuickHash IntHash file format + + + + + + QuickHash IntHash file format + + + + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to read the hash from. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is automatically calculated to be the same as the + number of entries in the hash, rounded up to the nearest power of two + with a maximum limit of 4194304. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntHash. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::loadFromFile</function> example + +exists( $key ) ? 'set' : 'unset' + ); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/loadfromstring.xml b/reference/quickhash/quickhashinthash/loadfromstring.xml new file mode 100644 index 0000000000..a6c12489ce --- /dev/null +++ b/reference/quickhash/quickhashinthash/loadfromstring.xml @@ -0,0 +1,130 @@ + + + + + + QuickHashIntHash::loadFromString + This factory method creates a hash from a string + + + + &reftitle.description; + + public static QuickHashIntHashQuickHashIntHash::loadFromString + stringcontents + integeroptions + + + This factory method creates a new hash from a definition in a string. The + file format consists of 32 bit signed integers packed together in the + Endianness that the system that the code runs on uses. For each element + there are two 32 bit signed integers stored. The first of each element is + the key, and the second is the value belonging to the key. + + + + + &reftitle.parameters; + + + + contents + + + The string containing a serialized format of the hash. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is automatically calculated to be the same as the + number of entries in the hash, rounded up to the nearest power of two + with a maximum limit of 4194304. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntHash. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::loadFromString</function> example + +exists( $key ) ? 'set' : 'unset' + ); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/savetofile.xml b/reference/quickhash/quickhashinthash/savetofile.xml new file mode 100644 index 0000000000..0b2b31d6c4 --- /dev/null +++ b/reference/quickhash/quickhashinthash/savetofile.xml @@ -0,0 +1,89 @@ + + + + + + QuickHashIntHash::saveToFile + This method stores an in-memory hash to disk. + + + + &reftitle.description; + + public voidQuickHashIntHash::saveToFile + stringfilename + + + This method stores an existing hash to a file on disk, in the same format + that loadFromFile() can read. + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to store the hash in. + + + + + + + + + &reftitle.returnvalues; + + This method doesn't return anything. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::saveToFile</function> example + +exists( 4 ) ); +var_dump( $hash->add( 4, 43 ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->add( 4, 52 ) ); + +$hash->saveToFile( '/tmp/test.hash' ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/savetostring.xml b/reference/quickhash/quickhashinthash/savetostring.xml new file mode 100644 index 0000000000..b8e6290d0c --- /dev/null +++ b/reference/quickhash/quickhashinthash/savetostring.xml @@ -0,0 +1,74 @@ + + + + + + QuickHashIntHash::saveToString + This method returns a serialized version of the hash. + + + + &reftitle.description; + + public stringQuickHashIntHash::saveToString + + + This method returns a serialized version of the hash in the same format that + loadFromString() can read. + + + + + &reftitle.returnvalues; + + This method returns a string containing a serialized format of the hash. + Each element is stored as a four byte value in the Endianness that the + current system uses. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::saveToString</function> example + +exists( 4 ) ); +var_dump( $hash->add( 4, 34 ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->add( 4, 55 ) ); + +var_dump( $hash->saveToString() ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/set.xml b/reference/quickhash/quickhashinthash/set.xml new file mode 100644 index 0000000000..bbe20014e7 --- /dev/null +++ b/reference/quickhash/quickhashinthash/set.xml @@ -0,0 +1,118 @@ + + + + + + QuickHashIntHash::set + This method updates an entry in the hash with a new value, or + adds a new one if the entry doesn't exist. + + + + &reftitle.description; + + public booleanQuickHashIntHash::set + integerkey + integervalue + + + This method tries to update an entry with a new value. In case the entry + did not yet exist, it will instead add a new entry. It returns whether the + entry was added or update. If there are duplicate keys, only the first + found element will get an updated value. Use + QuickHashIntHash::CHECK_FOR_DUPES during hash creation to prevent duplicate + keys from being part of the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add or update. + + + + + value + + + The new value to set the entry with. + + + + + + + + + &reftitle.returnvalues; + + 2 if the entry was found and updated, 1if the entry was newly added or 0 + if there was an error. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::set</function> example + +Add\n"; +var_dump( $hash->get( 46692 ) ); +var_dump( $hash->set( 46692, 16091 ) ); +var_dump( $hash->get( 46692 ) ); + +echo "Set->Update\n"; +var_dump( $hash->set( 46692, 29906 ) ); +var_dump( $hash->get( 46692 ) ); +?> +]]> + + &example.outputs.similar; + +Update +int(1) +int(29906) +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashinthash/update.xml b/reference/quickhash/quickhashinthash/update.xml new file mode 100644 index 0000000000..1492ecc4cd --- /dev/null +++ b/reference/quickhash/quickhashinthash/update.xml @@ -0,0 +1,107 @@ + + + + + + QuickHashIntHash::update + This method updates an entry in the hash with a new value. + + + + &reftitle.description; + + public booleanQuickHashIntHash::update + integerkey + integervalue + + + This method updates an entry with a new value, and returns whether the entry was + update. If there are duplicate keys, only the first found element will get + an updated value. Use QuickHashIntHash::CHECK_FOR_DUPES during hash + creation to prevent duplicate keys from being part of the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + value + + + The new value to update the entry with. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was found and updated, and &false; if the entry was + not part of the hash already. + + + + + &reftitle.examples; + + + <function>QuickHashIntHash::update</function> example + +add( 141421, 173205 ) ); +var_dump( $hash->update( 141421, 223606 ) ); +var_dump( $hash->get( 141421 ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintset.xml b/reference/quickhash/quickhashintset.xml new file mode 100644 index 0000000000..870b8fa715 --- /dev/null +++ b/reference/quickhash/quickhashintset.xml @@ -0,0 +1,158 @@ + + + + + + The QuickHashIntSet class + QuickHashIntSet + + + + +
+ &reftitle.intro; + + This class wraps around a set containing integer numbers. + + + Sets can also be iterated over with foreach as the Iterator interface is + implemented as well. The order of which elements are returned in is not + guaranteed. + +
+ + +
+ &reftitle.classsynopsis; + + + + QuickHashIntSet + + + + + QuickHashIntSet + + + + Constants + + const + integer + QuickHashIntSet::CHECK_FOR_DUPES + 1 + + + const + integer + QuickHashIntSet::DO_NOT_USE_ZEND_ALLOC + 2 + + + const + integer + QuickHashIntSet::HASHER_NO_HASH + 256 + + + const + integer + QuickHashIntSet::HASHER_JENKINS1 + 512 + + + const + integer + QuickHashIntSet::HASHER_JENKINS2 + 1024 + + + Methods + + + + +
+ + +
+ &reftitle.constants; +
+ QuickHashIntSet Node Types + + + + QuickHashIntSet::CHECK_FOR_DUPES + + If enabled, adding duplicate elements to a set (through either add() or + loadFromFile()) will result in those elements to be dropped from the + set. This will take up extra time, so only used when it is required. + + + + + QuickHashIntSet::DO_NOT_USE_ZEND_ALLOC + + Disables the use of PHP's internal memory manager for internal + set structures. With this option enabled, internal allocations will not + count towards the memory_limit settings. + + + + + QuickHashIntSet::HASHER_NO_HASH + + Selects to not use a hashing function, but merely use a modulo to + find the bucket list index. This is not faster than normal hashing, and + gives more collisions. + + + + + QuickHashIntSet::HASHER_JENKINS1 + + This is the default hashing function to turn the integer hashes + into bucket list indexes. + + + + + QuickHashIntSet::HASHER_JENKINS2 + + Selects a variant hashing algorithm. + + + + +
+
+ + + +
+ + &reference.quickhash.entities.quickhashintset; + +
+ + diff --git a/reference/quickhash/quickhashintset/add.xml b/reference/quickhash/quickhashintset/add.xml new file mode 100644 index 0000000000..c1081f0fa8 --- /dev/null +++ b/reference/quickhash/quickhashintset/add.xml @@ -0,0 +1,112 @@ + + + + + + QuickHashIntSet::add + This method adds a new entry to the set. + + + + &reftitle.description; + + public booleanQuickHashIntSet::add + integerkey + + + This method adds a new entry to the set, and returns whether the entry was + added. Entries are by default always added unless + QuickHashIntSet::CHECK_FOR_DUPES has been passed when the set was created. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was added, and &false; if the entry was not added. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::add</function> example + +exists( 4 ) ); +var_dump( $set->add( 4 ) ); +var_dump( $set->exists( 4 ) ); +var_dump( $set->add( 4 ) ); + +echo "\nwith dupe checking\n"; +$set = new QuickHashIntSet( 1024, QuickHashIntSet::CHECK_FOR_DUPES ); +var_dump( $set->exists( 4 ) ); +var_dump( $set->add( 4 ) ); +var_dump( $set->exists( 4 ) ); +var_dump( $set->add( 4 ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/construct.xml b/reference/quickhash/quickhashintset/construct.xml new file mode 100644 index 0000000000..9db287d4ef --- /dev/null +++ b/reference/quickhash/quickhashintset/construct.xml @@ -0,0 +1,108 @@ + + + + + + QuickHashIntSet::__construct + Creates a new QuickHashIntSet object + + + + &reftitle.description; + + QuickHashIntSet::__construct + integersize + integeroptions + + + This constructor creates a new QuickHashIntSet. The size is the amount of + bucket lists to create. The more lists there are, the less collisions you + will have. Options are also supported. + + + + + &reftitle.parameters; + + + + size + + + The amount of bucket lists to configure. The number you pass in will be + automatically rounded up to the next power of two. It is also + automatically limited from 4 to 4194304. + + + + + options + + + The options that you can pass in are: QuickHashIntSet::CHECK_FOR_DUPES, + which makes sure no duplicate entries are added to the set; + QuickHashIntSet::DO_NOT_USE_ZEND_ALLOC to not use PHP's internal memory + manager as well as one of QuickHashIntSet::HASHER_NO_HASH, + QuickHashIntSet::HASHER_JENKINS1 or QuickHashIntSet::HASHER_JENKINS2. + These last three configure which hashing algorithm to use. All options + can be combined using bitmasks. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntSet object. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::__construct</function> example + + +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/delete.xml b/reference/quickhash/quickhashintset/delete.xml new file mode 100644 index 0000000000..b25603ea3d --- /dev/null +++ b/reference/quickhash/quickhashintset/delete.xml @@ -0,0 +1,97 @@ + + + + + + QuickHashIntSet::delete + This method deletes an entry from the set. + + + + &reftitle.description; + + public booleanQuickHashIntSet::delete + integerkey + + + This method deletes an entry from the set, and returns whether the entry was + deleted or not. Associated memory structures will not be freed immediately, + but rather when the set itself is freed. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to delete. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was deleted, and &false; if the entry was not deleted. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::delete</function> example + +exists( 4 ) ); +var_dump( $set->add( 4 ) ); +var_dump( $set->delete( 4 ) ); +var_dump( $set->exists( 4 ) ); +var_dump( $set->delete( 4 ) ); +?>]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/exists.xml b/reference/quickhash/quickhashintset/exists.xml new file mode 100644 index 0000000000..1457dae129 --- /dev/null +++ b/reference/quickhash/quickhashintset/exists.xml @@ -0,0 +1,112 @@ + + + + + + QuickHashIntSet::exists + This method checks whether a key is part of the set + + + + &reftitle.description; + + public booleanQuickHashIntSet::exists + integerkey + + + This method checks whether an entry with the provided key exists in the + set. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to check for whether it exists in the set. + + + + + + + + + &reftitle.returnvalues; + + Returns &true; when the entry was found, or &false; when the entry is not + found. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::exists</function> example + +add( $key ); +} + +echo "Doing 1000 tests: ", microtime( true ), "\n"; +foreach( $testForEntries as $key ) +{ + $foundCount += $set->exists( $key ); +} +echo "Done, $foundCount found: ", microtime( true ), "\n"; +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/getsize.xml b/reference/quickhash/quickhashintset/getsize.xml new file mode 100644 index 0000000000..c468325cce --- /dev/null +++ b/reference/quickhash/quickhashintset/getsize.xml @@ -0,0 +1,92 @@ + + + + + + QuickHashIntSet::getSize + Returns the number of elements in the set + + + + &reftitle.description; + + publicintegerQuickHashIntSet::getSize + + + Returns the number of elements in the set. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + The number of elements in the set. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::getSize</function> example + +add( 2 ) ); +var_dump( $set->add( 3 ) ); +var_dump( $set->getSize() ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/loadfromfile.xml b/reference/quickhash/quickhashintset/loadfromfile.xml new file mode 100644 index 0000000000..7ec16e03bf --- /dev/null +++ b/reference/quickhash/quickhashintset/loadfromfile.xml @@ -0,0 +1,128 @@ + + + + + + QuickHashIntSet::loadFromFile + This factory method creates a set from a file + + + + &reftitle.description; + + public static QuickHashIntSetQuickHashIntSet::loadFromFile + stringfilename + integeroptions + + + This factory method creates a new set from a definition file on disk. The + file format consists of 32 bit signed integers packed together in the + Endianness that the system that the code runs on uses. + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to read the set from. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is automatically calculated to be the same as the + number of entries in the set, rounded up to the nearest power of two + with a maximum limit of 4194304. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntSet. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::loadFromFile</function> example + +exists( $key ) ? 'set' : 'unset' + ); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/loadfromstring.xml b/reference/quickhash/quickhashintset/loadfromstring.xml new file mode 100644 index 0000000000..b32dbe31dc --- /dev/null +++ b/reference/quickhash/quickhashintset/loadfromstring.xml @@ -0,0 +1,128 @@ + + + + + + QuickHashIntSet::loadFromString + This factory method creates a set from a string + + + + &reftitle.description; + + public static QuickHashIntSetQuickHashIntSet::loadFromString + stringcontents + integeroptions + + + This factory method creates a new set from a definition in a string. The + file format consists of 32 bit signed integers packed together in the + Endianness that the system that the code runs on uses. + + + + + &reftitle.parameters; + + + + contents + + + The string containing a serialized format of the set. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is automatically calculated to be the same as the + number of entries in the set, rounded up to the nearest power of two + automatically limited from 64 to 4194304. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntSet. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::loadFromString</function> example + +exists( $key ) ? 'set' : 'unset' + ); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/savetofile.xml b/reference/quickhash/quickhashintset/savetofile.xml new file mode 100644 index 0000000000..213069c7ce --- /dev/null +++ b/reference/quickhash/quickhashintset/savetofile.xml @@ -0,0 +1,89 @@ + + + + + + QuickHashIntSet::saveToFile + This method stores an in-memory set to disk. + + + + &reftitle.description; + + public voidQuickHashIntSet::saveToFile + stringfilename + + + This method stores an existing set to a file on disk, in the same format + that loadFromFile() can read. + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to store the hash in. + + + + + + + + + &reftitle.returnvalues; + + This method doesn't return anything. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::saveToFile</function> example + +exists( 4 ) ); +var_dump( $set->add( 4 ) ); +var_dump( $set->exists( 4 ) ); +var_dump( $set->add( 4 ) ); + +$set->saveToFile( '/tmp/test.set' ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashintset/savetostring.xml b/reference/quickhash/quickhashintset/savetostring.xml new file mode 100644 index 0000000000..a1aeb90bfd --- /dev/null +++ b/reference/quickhash/quickhashintset/savetostring.xml @@ -0,0 +1,74 @@ + + + + + + QuickHashIntSet::saveToString + This method returns a serialized version of the set. + + + + &reftitle.description; + + public stringQuickHashIntSet::saveToString + + + This method returns a serialized version of the set in the same format that + loadFromString() can read. + + + + + &reftitle.returnvalues; + + This method returns a string containing a serialized format of the set. + Each element is stored as a four byte value in the Endianness that the + current system uses. + + + + + &reftitle.examples; + + + <function>QuickHashIntSet::saveToString</function> example + +exists( 4 ) ); +var_dump( $set->add( 4 ) ); +var_dump( $set->exists( 4 ) ); +var_dump( $set->add( 4 ) ); + +var_dump( $set->saveToString() ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash.xml b/reference/quickhash/quickhashintstringhash.xml new file mode 100644 index 0000000000..c5f20a2de3 --- /dev/null +++ b/reference/quickhash/quickhashintstringhash.xml @@ -0,0 +1,160 @@ + + + + + + The QuickHashIntStringHash class + QuickHashIntStringHash + + + + +
+ &reftitle.intro; + + This class wraps around a hash containing integer numbers, where the + values are strings. Hashes are also available as implementation of the + ArrayAccess interface. + + + Hashes can also be iterated over with foreach as the Iterator interface is + implemented as well. The order of which elements are returned in is not + guaranteed. + +
+ + +
+ &reftitle.classsynopsis; + + + + QuickHashIntStringHash + + + + + QuickHashIntStringHash + + + + Constants + + const + integer + QuickHashIntStringHash::CHECK_FOR_DUPES + 1 + + + const + integer + QuickHashIntStringHash::DO_NOT_USE_ZEND_ALLOC + 2 + + + const + integer + QuickHashIntStringHash::HASHER_NO_HASH + 256 + + + const + integer + QuickHashIntStringHash::HASHER_JENKINS1 + 512 + + + const + integer + QuickHashIntStringHash::HASHER_JENKINS2 + 1024 + + + Methods + + + + +
+ + +
+ &reftitle.constants; +
+ QuickHashIntStringHash Node Types + + + + QuickHashIntStringHash::CHECK_FOR_DUPES + + If enabled, adding duplicate elements to a set (through either add() or + loadFromFile()) will result in those elements to be dropped from the + set. This will take up extra time, so only used when it is required. + + + + + QuickHashIntStringHash::DO_NOT_USE_ZEND_ALLOC + + Disables the use of PHP's internal memory manager for internal + set structures. With this option enabled, internal allocations will not + count towards the memory_limit settings. + + + + + QuickHashIntStringHash::HASHER_NO_HASH + + Selects to not use a hashing function, but merely use a modulo to + find the bucket list index. This is not faster than normal hashing, and + gives more collisions. + + + + + QuickHashIntStringHash::HASHER_JENKINS1 + + This is the default hashing function to turn the integer hashes + into bucket list indexes. + + + + + QuickHashIntStringHash::HASHER_JENKINS2 + + Selects a variant hashing algorithm. + + + + +
+
+ + + +
+ + &reference.quickhash.entities.quickhashintstringhash; + +
+ + diff --git a/reference/quickhash/quickhashintstringhash/add.xml b/reference/quickhash/quickhashintstringhash/add.xml new file mode 100644 index 0000000000..e49398bc3a --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/add.xml @@ -0,0 +1,130 @@ + + + + + + QuickHashIntStringHash::add + This method adds a new entry to the hash. + + + + &reftitle.description; + + public booleanQuickHashIntStringHash::add + integerkey + stringvalue + + + This method adds a new entry to the hash, and returns whether the entry was + added. Entries are by default always added unless + QuickHashIntStringHash::CHECK_FOR_DUPES has been passed when the hash was created. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + value + + + The value of the entry to add. If a non-string is passed, it will be + converted to a string automatically if possible. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was added, and &false; if the entry was not added. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::add</function> example + +exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, "twenty two" ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, "twelve" ) ); + +echo "\nwith dupe checking\n"; +$hash = new QuickHashIntStringHash( 1024, QuickHashIntStringHash::CHECK_FOR_DUPES ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, "seventy eight" ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->get( 4 ) ); +var_dump( $hash->add( 4, "nine" ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/construct.xml b/reference/quickhash/quickhashintstringhash/construct.xml new file mode 100644 index 0000000000..81459d338d --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/construct.xml @@ -0,0 +1,108 @@ + + + + + + QuickHashIntStringHash::__construct + Creates a new QuickHashIntStringHash object + + + + &reftitle.description; + + QuickHashIntStringHash::__construct + integersize + integeroptions + + + This constructor creates a new QuickHashIntStringHash. The size is the amount of + bucket lists to create. The more lists there are, the less collisions you + will have. Options are also supported. + + + + + &reftitle.parameters; + + + + size + + + The amount of bucket lists to configure. The number you pass in will be + automatically rounded up to the next power of two. It is also + automatically limited from 64 to 4194304. + + + + + options + + + The options that you can pass in are: QuickHashIntStringHash::CHECK_FOR_DUPES, + which makes sure no duplicate entries are added to the hash; + QuickHashIntStringHash::DO_NOT_USE_ZEND_ALLOC to not use PHP's internal memory + manager as well as one of QuickHashIntStringHash::HASHER_NO_HASH, + QuickHashIntStringHash::HASHER_JENKINS1 or QuickHashIntStringHash::HASHER_JENKINS2. + These last three configure which hashing algorithm to use. All options + can be combined using bitmasks. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntStringHash object. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::__construct</function> example + + +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/delete.xml b/reference/quickhash/quickhashintstringhash/delete.xml new file mode 100644 index 0000000000..e9062be904 --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/delete.xml @@ -0,0 +1,102 @@ + + + + + + QuickHashIntStringHash::delete + This method deletes am entry from the hash. + + + + &reftitle.description; + + public booleanQuickHashIntStringHash::delete + integerkey + + + This method deletes an entry from the hash, and returns whether the entry was + deleted or not. Associated memory structures will not be freed immediately, + but rather when the hash itself is freed. + + + Elements can not be deleted when the hash is used in an iterator. The + method will not throw an exception, but simply return &false; like would + happen with any other deletion failure. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to delete. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was deleted, and &false; if the entry was not deleted. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::delete</function> example + +exists( 4 ) ); +var_dump( $hash->add( 4, "five" ) ); +var_dump( $hash->delete( 4 ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->delete( 4 ) ); +?>]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/exists.xml b/reference/quickhash/quickhashintstringhash/exists.xml new file mode 100644 index 0000000000..4a376d949a --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/exists.xml @@ -0,0 +1,67 @@ + + + + + + QuickHashIntStringHash::exists + This method checks whether a key is part of the hash + + + + &reftitle.description; + + public booleanQuickHashIntStringHash::exists + integerkey + + + This method checks whether an entry with the provided key exists in the + hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to check for whether it exists in the hash. + + + + + + + + + &reftitle.returnvalues; + + Returns &true; when the entry was found, or &false; when the entry is not + found. + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/get.xml b/reference/quickhash/quickhashintstringhash/get.xml new file mode 100644 index 0000000000..515ee7d97c --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/get.xml @@ -0,0 +1,99 @@ + + + + + + QuickHashIntStringHash::get + This method retrieves a value from the hash by its key. + + + + &reftitle.description; + + public integerQuickHashIntStringHash::get + integerkey + + + This method retrieves a value from the hash by its key. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + The value if the key exists, or &null; if the key wasn't part of the hash. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::get</function> example + +get( 1 ) ); + +var_dump( $hash->add( 2, "two" ) ); +var_dump( $hash->get( 2 ) ); + +var_dump( $hash->add( 3, 5 ) ); +var_dump( $hash->get( 3 ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/getsize.xml b/reference/quickhash/quickhashintstringhash/getsize.xml new file mode 100644 index 0000000000..dfbfcec9ed --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/getsize.xml @@ -0,0 +1,76 @@ + + + + + + QuickHashIntStringHash::getSize + Returns the number of elements in the hash + + + + &reftitle.description; + + public integerQuickHashIntStringHash::getSize + + + Returns the number of elements in the hash. + + + + + &reftitle.returnvalues; + + The number of elements in the hash. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::getSize</function> example + +add( 2, "two" ) ); +var_dump( $hash->add( 3, 5 ) ); +var_dump( $hash->getSize() ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/loadfromfile.xml b/reference/quickhash/quickhashintstringhash/loadfromfile.xml new file mode 100644 index 0000000000..0bf9b8e1c5 --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/loadfromfile.xml @@ -0,0 +1,170 @@ + + + + + + QuickHashIntStringHash::loadFromFile + This factory method creates a hash from a file + + + + &reftitle.description; + + public static QuickHashIntStringHashQuickHashIntStringHash::loadFromFile + stringfilename + integeroptions + + + This factory method creates a new hash from a definition file on disk. The + file format consists of a signature 'QH\0x12\0', the number of elements as + a 32 bit signed integer in system Endianness, an unsigned 32 bit integer + containing the number of element data to follow in characters. This element + data contains all the strings. After the header and the strings, the + elements follow in pairs of two unsigned 32 bit integers where the first + one is the key, and the second one the index in the the element data + string. An example could be: + + + + QuickHash IntString file format + + + + + + QuickHash IntString file format + + + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to read the hash from. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is automatically calculated to be the same as the + number of entries in the hash, rounded up to the nearest power of two + with a maximum limit of 4194304. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntStringHash. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::loadFromFile</function> example + +exists( $key ) ? 'set' : 'unset' + ); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/loadfromstring.xml b/reference/quickhash/quickhashintstringhash/loadfromstring.xml new file mode 100644 index 0000000000..439fc5a271 --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/loadfromstring.xml @@ -0,0 +1,127 @@ + + + + + + QuickHashIntStringHash::loadFromString + This factory method creates a hash from a string + + + + &reftitle.description; + + public static QuickHashIntStringHashQuickHashIntStringHash::loadFromString + stringcontents + integeroptions + + + This factory method creates a new hash from a definition in a string. The + format is the same as the one used in "loadFromFile". + + + + + &reftitle.parameters; + + + + contents + + + The string containing a serialized format of the hash. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is automatically calculated to be the same as the + number of entries in the hash, rounded up to the nearest power of two + with a maximum limit of 4194304. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashIntStringHash. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::loadFromString</function> example + +exists( $key ) ? 'set' : 'unset' + ); +} +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/savetofile.xml b/reference/quickhash/quickhashintstringhash/savetofile.xml new file mode 100644 index 0000000000..8e1ad10d7f --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/savetofile.xml @@ -0,0 +1,89 @@ + + + + + + QuickHashIntStringHash::saveToFile + This method stores an in-memory hash to disk. + + + + &reftitle.description; + + public voidQuickHashIntStringHash::saveToFile + stringfilename + + + This method stores an existing hash to a file on disk, in the same format + that loadFromFile() can read. + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to store the hash in. + + + + + + + + + &reftitle.returnvalues; + + This method doesn't return anything. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::saveToFile</function> example + +exists( 4 ) ); +var_dump( $hash->add( 4, "fourty three" ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->add( 4, "fifty two" ) ); + +$hash->saveToFile( '/tmp/test.string.hash' ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/savetostring.xml b/reference/quickhash/quickhashintstringhash/savetostring.xml new file mode 100644 index 0000000000..8aea34130d --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/savetostring.xml @@ -0,0 +1,74 @@ + + + + + + QuickHashIntStringHash::saveToString + This method returns a serialized version of the hash. + + + + &reftitle.description; + + public stringQuickHashIntStringHash::saveToStringe + + + This method returns a serialized version of the hash in the same format that + loadFromString() can read. + + + + + &reftitle.returnvalues; + + This method returns a string containing a serialized format of the hash. + Each element is stored as a four byte value in the Endianness that the + current system uses. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::saveToString</function> example + +exists( 4 ) ); +var_dump( $hash->add( 4, "thirty four" ) ); +var_dump( $hash->exists( 4 ) ); +var_dump( $hash->add( 5, "fifty five" ) ); + +var_dump( $hash->saveToString() ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/set.xml b/reference/quickhash/quickhashintstringhash/set.xml new file mode 100644 index 0000000000..385a90624d --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/set.xml @@ -0,0 +1,120 @@ + + + + + + QuickHashIntStringHash::set + This method updates an entry in the hash with a new value, or + adds a new one if the entry doesn't exist. + + + + &reftitle.description; + + public booleanQuickHashIntStringHash::set + integerkey + stringvalue + + + This method tries to update an entry with a new value. In case the entry + did not yet exist, it will instead add a new entry. It returns whether the + entry was added or update. If there are duplicate keys, only the first + found element will get an updated value. Use + QuickHashIntStringHash::CHECK_FOR_DUPES during hash creation to prevent duplicate + keys from being part of the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add or update. + + + + + value + + + The value of the entry to add. If a non-string is passed, it will be + converted to a string automatically if possible. + + + + + + + + + &reftitle.returnvalues; + + 2 if the entry was found and updated, 1 if the entry was newly added or 0 + if there was an error. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::set</function> example + +Add\n"; +var_dump( $hash->get( 46692 ) ); +var_dump( $hash->set( 46692, "sixteen thousand ninety one" ) ); +var_dump( $hash->get( 46692 ) ); + +echo "Set->Update\n"; +var_dump( $hash->set( 46692, "twenty nine thousand nine hundred six" ) ); +var_dump( $hash->get( 46692 ) ); +?> +]]> + + &example.outputs.similar; + +Add +bool(false) +int(2) +string(27) "sixteen thousand ninety one" +Set->Update +int(1) +string(37) "twenty nine thousand nine hundred six" +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashintstringhash/update.xml b/reference/quickhash/quickhashintstringhash/update.xml new file mode 100644 index 0000000000..d56ca5aec9 --- /dev/null +++ b/reference/quickhash/quickhashintstringhash/update.xml @@ -0,0 +1,117 @@ + + + + + + QuickHashIntStringHash::update + This method updates an entry in the hash with a new value. + + + + &reftitle.description; + + public booleanQuickHashIntStringHash::update + integerkey + stringvalue + + + This method updates an entry with a new value, and returns whether the entry was + update. If there are duplicate keys, only the first found element will get + an updated value. Use QuickHashIntStringHash::CHECK_FOR_DUPES during hash + creation to prevent duplicate keys from being part of the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + value + + + The new value for the entry. If a non-string is passed, it will be + converted to a string automatically if possible. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was found and updated, and &false; if the entry was + not part of the hash already. + + + + + &reftitle.examples; + + + <function>QuickHashIntStringHash::update</function> example + +add( 161803398, "--" ); +$hash->add( 314159265, "a lot" ); + +echo $hash->get( 161803398 ), "\n"; +echo $hash->get( 314159265 ), "\n"; + +var_dump( $hash->update( 314159265, "a lot plus one" ) ); +var_dump( $hash->update( 314159999, "a lot plus one" ) ); + +echo $hash->get( 161803398 ), "\n"; +echo $hash->get( 314159265 ), "\n"; +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash.xml b/reference/quickhash/quickhashstringinthash.xml new file mode 100644 index 0000000000..4f32b74b24 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash.xml @@ -0,0 +1,118 @@ + + + + + + The QuickHashStringIntHash class + QuickHashStringIntHash + + + + +
+ &reftitle.intro; + + This class wraps around a hash containing strings, where the + values are integer numbers. Hashes are also available as + implementation of the ArrayAccess interface. + + + Hashes can also be iterated over with foreach as the Iterator interface is + implemented as well. The order of which elements are returned in is not + guaranteed. + +
+ + +
+ &reftitle.classsynopsis; + + + + QuickHashStringIntHash + + + + + QuickHashStringIntHash + + + + Constants + + const + integer + QuickHashStringIntHash::CHECK_FOR_DUPES + 1 + + + const + integer + QuickHashStringIntHash::DO_NOT_USE_ZEND_ALLOC + 2 + + + Methods + + + + +
+ + +
+ &reftitle.constants; +
+ QuickHashStringIntHash Node Types + + + + QuickHashStringIntHash::CHECK_FOR_DUPES + + If enabled, adding duplicate elements to a set (through either add() or + loadFromFile()) will result in those elements to be dropped from the + set. This will take up extra time, so only used when it is required. + + + + + QuickHashStringIntHash::DO_NOT_USE_ZEND_ALLOC + + Disables the use of PHP's internal memory manager for internal + set structures. With this option enabled, internal allocations will not + count towards the memory_limit settings. + + + + +
+
+ + + +
+ + &reference.quickhash.entities.quickhashstringinthash; + +
+ + diff --git a/reference/quickhash/quickhashstringinthash/add.xml b/reference/quickhash/quickhashstringinthash/add.xml new file mode 100644 index 0000000000..08e21e508c --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/add.xml @@ -0,0 +1,135 @@ + + + + + + QuickHashStringIntHash::add + This method adds a new entry to the hash. + + + + &reftitle.description; + + public booleanQuickHashStringIntHash::add + stringkey + intvalue + + + This method adds a new entry to the hash, and returns whether the entry was + added. Entries are by default always added unless + QuickHashStringIntHash::CHECK_FOR_DUPES has been passed when the hash was created. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + value + + + The value of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was added, and &false; if the entry was not added. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::add</function> example + +exists( "four" ) ); +var_dump( $hash->get( "four" ) ); +var_dump( $hash->add( "four", 22 ) ); +var_dump( $hash->exists( "four" ) ); +var_dump( $hash->get( "four" ) ); +var_dump( $hash->add( "four", 12 ) ); + +echo "\nwith dupe checking\n"; +$hash = new QuickHashStringIntHash( 1024, QuickHashStringIntHash::CHECK_FOR_DUPES ); +var_dump( $hash ); +var_dump( $hash->exists( "four" ) ); +var_dump( $hash->get( "four" ) ); +var_dump( $hash->add( "four", 78 ) ); +var_dump( $hash->exists( "four" ) ); +var_dump( $hash->get( "four" ) ); +var_dump( $hash->add( "four", 9 ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/construct.xml b/reference/quickhash/quickhashstringinthash/construct.xml new file mode 100644 index 0000000000..3b28e30946 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/construct.xml @@ -0,0 +1,100 @@ + + + + + + QuickHashStringIntHash::__construct + Creates a new QuickHashStringIntHash object + + + + &reftitle.description; + + QuickHashStringIntHash::__construct + integersize + integeroptions + + + This constructor creates a new QuickHashStringIntHash. The size is the amount of + bucket lists to create. The more lists there are, the less collisions you + will have. Options are also supported. + + + + + &reftitle.parameters; + + + + size + + + The amount of bucket lists to configure. The number you pass in will be + automatically rounded up to the next power of two. It is also + automatically limited from 64 to 4194304. + + + + + options + + + The options that you can pass in are: + QuickHashStringIntHash::CHECK_FOR_DUPES, which makes sure no duplicate + entries are added to the hash and + QuickHashStringIntHash::DO_NOT_USE_ZEND_ALLOC to not use PHP's internal + memory manager. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashStringIntHash object. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::__construct</function> example + + +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/delete.xml b/reference/quickhash/quickhashstringinthash/delete.xml new file mode 100644 index 0000000000..90748caa27 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/delete.xml @@ -0,0 +1,106 @@ + + + + + + QuickHashStringIntHash::delete + This method deletes am entry from the hash. + + + + &reftitle.description; + + public booleanQuickHashStringIntHash::delete + stringkey + + + This method deletes an entry from the hash, and returns whether the entry was + deleted or not. Associated memory structures will not be freed immediately, + but rather when the hash itself is freed. + + + Elements can not be deleted when the hash is used in an iterator. The + method will not throw an exception, but simply return &false; like would + happen with any other deletion failure. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to delete. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was deleted, and &false; if the entry was not deleted. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::delete</function> example + +exists( 'four' ) ); +var_dump( $hash->add( 'four', 5 ) ); +var_dump( $hash->get( 'four' ) ); +var_dump( $hash->delete( 'four' ) ); +var_dump( $hash->exists( 'four' ) ); +var_dump( $hash->get( 'four' ) ); +var_dump( $hash->delete( 'four' ) ); +?>]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/exists.xml b/reference/quickhash/quickhashstringinthash/exists.xml new file mode 100644 index 0000000000..dc7340496f --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/exists.xml @@ -0,0 +1,67 @@ + + + + + + QuickHashStringIntHash::exists + This method checks whether a key is part of the hash + + + + &reftitle.description; + + public booleanQuickHashStringIntHash::exists + stringkey + + + This method checks whether an entry with the provided key exists in the + hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to check for whether it exists in the hash. + + + + + + + + + &reftitle.returnvalues; + + Returns &true; when the entry was found, or &false; when the entry is not + found. + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/get.xml b/reference/quickhash/quickhashstringinthash/get.xml new file mode 100644 index 0000000000..1880baa929 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/get.xml @@ -0,0 +1,94 @@ + + + + + + QuickHashStringIntHash::get + This method retrieves a value from the hash by its key. + + + + &reftitle.description; + + public integerQuickHashStringIntHash::get + stringkey + + + This method retrieves a value from the hash by its key. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + The value if the key exists, or &null; if the key wasn't part of the hash. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::get</function> example + +get( "one" ) ); + +var_dump( $hash->add( "two", 2 ) ); +var_dump( $hash->get( "two" ) ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/getsize.xml b/reference/quickhash/quickhashstringinthash/getsize.xml new file mode 100644 index 0000000000..a05cce40bd --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/getsize.xml @@ -0,0 +1,92 @@ + + + + + + QuickHashStringIntHash::getSize + Returns the number of elements in the hash + + + + &reftitle.description; + + public integerQuickHashStringIntHash::getSize + + + Returns the number of elements in the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + + + + + &reftitle.returnvalues; + + The number of elements in the hash. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::getSize</function> example + +add( "two", 2 ) ); +var_dump( $hash->add( "three", 5 ) ); +var_dump( $hash->getSize() ); +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/loadfromfile.xml b/reference/quickhash/quickhashstringinthash/loadfromfile.xml new file mode 100644 index 0000000000..de008dafb5 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/loadfromfile.xml @@ -0,0 +1,181 @@ + + + + + + QuickHashStringIntHash::loadFromFile + This factory method creates a hash from a file + + + + &reftitle.description; + + public static QuickHashStringIntHashQuickHashStringIntHash::loadFromFile + stringfilename + integeroptions + + + This factory method creates a new hash from a definition file on disk. The + file format consists of a signature 'QH\0x21\0', the number of elements as + a 32 bit signed integer in system Endianness, an unsigned 32 bit integer + containing the number of element data to follow in characters. This element + data contains all the strings. The follows another signed 32 bit integer + containing the number of bucket lists. After the header and the strings, + the elements follow. They are ordered by bucket list so that the keys don't + have to be hashed in order to restore the hash. For each bucket list, the + following information is stored (all as 32 bit integers): the bucket list + index, the number of elements in that list, and then in pairs of two + unsigned 32 bit integers the elements, where the first one is the index + into the string list containing the keys, and the second one the value. An + example could be: + + + + QuickHash StringIntHash file format + + + + + + QuickHash IntHash file format + + + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to read the hash from. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is read from the file format (unlike the + QuickHashIntHash and QuickhashIntStringHash classes, where it is + automatically calculated from the number of entries in the hash.) + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashStringIntHash. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::loadFromFile</function> example + + ', $hash->get( $k ), "\n"; +} +?> +]]> + + &example.outputs.similar; + + 48712 +12uf => 50343 +143q => 51974 +15d1 => 53605 +16mc => 55236 +17vn => 56867 +194y => 58498 +1ae9 => 60129 +1bnk => 61760 +1cwv => 63391 +1e66 => 65022 +1ffh => 66653 +1gos => 68284 +1hy3 => 69915 +1j7e => 71546 +1kgp => 73177 +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/loadfromstring.xml b/reference/quickhash/quickhashstringinthash/loadfromstring.xml new file mode 100644 index 0000000000..884d89330e --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/loadfromstring.xml @@ -0,0 +1,126 @@ + + + + + + QuickHashStringIntHash::loadFromString + This factory method creates a hash from a string + + + + &reftitle.description; + + public static QuickHashStringIntHashQuickHashStringIntHash::loadFromString + stringcontents + integeroptions + + + This factory method creates a new hash from a definition in a string. The + format is the same as the one used in "loadFromFile". + + + + + &reftitle.parameters; + + + + contents + + + The string containing a serialized format of the hash. + + + + + options + + + The same options that the class' contructor takes; except that the size + option is ignored. It is automatically calculated to be the same as the + number of entries in the hash, rounded up to the nearest power of two + with a maximum limit of 4194304. + + + + + + + + + &reftitle.returnvalues; + + Returns a new QuickHashStringIntHash. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::loadFromString</function> example + + ', $hash->get( $k ), "\n"; +} +?> +]]> + + &example.outputs.similar; + + 48712 +12uf => 50343 +143q => 51974 +15d1 => 53605 +16mc => 55236 +17vn => 56867 +194y => 58498 +1ae9 => 60129 +1bnk => 61760 +1cwv => 63391 +1e66 => 65022 +1ffh => 66653 +1gos => 68284 +1hy3 => 69915 +1j7e => 71546 +1kgp => 73177 +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/savetofile.xml b/reference/quickhash/quickhashstringinthash/savetofile.xml new file mode 100644 index 0000000000..ba24aa01f7 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/savetofile.xml @@ -0,0 +1,87 @@ + + + + + + QuickHashStringIntHash::saveToFile + This method stores an in-memory hash to disk. + + + + &reftitle.description; + + public voidQuickHashStringIntHash::saveToFile + stringfilename + + + This method stores an existing hash to a file on disk, in the same format + that loadFromFile() can read. + + + + + &reftitle.parameters; + + + + filename + + + The filename of the file to store the hash in. + + + + + + + + + &reftitle.returnvalues; + + This method doesn't return anything. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::saveToFile</function> example + +add( "fourty three", 42 ) ); +var_dump( $hash->add( "fifty two", 52 ) ); + +$hash->saveToFile( '/tmp/test.hash.string' ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/savetostring.xml b/reference/quickhash/quickhashstringinthash/savetostring.xml new file mode 100644 index 0000000000..be6581b86f --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/savetostring.xml @@ -0,0 +1,71 @@ + + + + + + QuickHashStringIntHash::saveToString + This method returns a serialized version of the hash. + + + + &reftitle.description; + + public stringQuickHashStringIntHash::saveToString + + + This method returns a serialized version of the hash in the same format that + loadFromString() can read. + + + + + &reftitle.returnvalues; + + This method returns a serialized format of an existing hash, in the same format + that loadFromString() can read. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::saveToString</function> example + +add( "fourty three", 42 ) ); +var_dump( $hash->add( "fifty two", 52 ) ); + +var_dump( $hash->saveToString() ); +?> +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/set.xml b/reference/quickhash/quickhashstringinthash/set.xml new file mode 100644 index 0000000000..f1f5b8a2b9 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/set.xml @@ -0,0 +1,120 @@ + + + + + + QuickHashStringIntHash::set + This method updates an entry in the hash with a new value, or + adds a new one if the entry doesn't exist. + + + + &reftitle.description; + + public booleanQuickHashStringIntHash::set + stringkey + intvalue + + + This method tries to update an entry with a new value. In case the entry + did not yet exist, it will instead add a new entry. It returns whether the + entry was added or update. If there are duplicate keys, only the first + found element will get an updated value. Use + QuickHashStringIntHash::CHECK_FOR_DUPES during hash creation to prevent duplicate + keys from being part of the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add or update. + + + + + value + + + The value of the entry to add. If a non-string is passed, it will be + converted to a string automatically if possible. + + + + + + + + + &reftitle.returnvalues; + + 2 if the entry was found and updated, 1 if the entry was newly added or 0 + if there was an error. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::set</function> example + +Add\n"; +var_dump( $hash->get( "fourty six thousand six hundred ninety two" ) ); +var_dump( $hash->set( "fourty six thousand six hundred ninety two", 16091 ) ); +var_dump( $hash->get( "fourty six thousand six hundred ninety two" ) ); + +echo "Set->Update\n"; +var_dump( $hash->set( "fourty six thousand six hundred ninety two", 29906 ) ); +var_dump( $hash->get( "fourty six thousand six hundred ninety two" ) ); +?> +]]> + + &example.outputs.similar; + +Add +bool(false) +int(2) +int(16091) +Set->Update +int(1) +int(29906) +]]> + + + + + + + + + diff --git a/reference/quickhash/quickhashstringinthash/update.xml b/reference/quickhash/quickhashstringinthash/update.xml new file mode 100644 index 0000000000..3fe473d570 --- /dev/null +++ b/reference/quickhash/quickhashstringinthash/update.xml @@ -0,0 +1,119 @@ + + + + + + QuickHashStringIntHash::update + This method updates an entry in the hash with a new value. + + + + &reftitle.description; + + public booleanQuickHashStringIntHash::update + stringkey + integervalue + + + This method updates an entry with a new value, and returns whether the entry was + update. If there are duplicate keys, only the first found element will get + an updated value. Use QuickHashStringIntHash::CHECK_FOR_DUPES during hash + creation to prevent duplicate keys from being part of the hash. + + + + + &reftitle.parameters; + + + + key + + + The key of the entry to add. + + + + + value + + + The new value for the entry. If a non-string is passed, it will be + converted to a string automatically if possible. + + + + + + + + + &reftitle.returnvalues; + + &true; when the entry was found and updated, and &false; if the entry was + not part of the hash already. + + + + + &reftitle.examples; + + + <function>QuickHashStringIntHash::update</function> example + +add( 'six', 314159265 ); +$hash->add( "a lot", 314159265 ); + +echo $hash->get( 'six' ), "\n"; +echo $hash->get( 'a lot' ), "\n"; + +var_dump( $hash->update( 'a lot', 314159266 ) ); +var_dump( $hash->update( "a lot plus one", 314159999 ) ); + +echo $hash->get( 'six' ), "\n"; +echo $hash->get( 'a lot' ), "\n"; +?> +]]> + + &example.outputs.similar; + + + + + + + + + + + diff --git a/reference/quickhash/reference.xml b/reference/quickhash/reference.xml new file mode 100644 index 0000000000..d261af0e4f --- /dev/null +++ b/reference/quickhash/reference.xml @@ -0,0 +1,31 @@ + + + + + Quickhash &Functions; + + &reference.quickhash.entities.functions; + + + + + diff --git a/reference/quickhash/setup.xml b/reference/quickhash/setup.xml new file mode 100644 index 0000000000..4c31a632ba --- /dev/null +++ b/reference/quickhash/setup.xml @@ -0,0 +1,49 @@ + + + + + &reftitle.setup; + +
+ &reftitle.required; + + This extension requires no additional libraries. + +
+ +
+ &reftitle.install; + + &pecl.info; + &url.pecl.package;quickhash + +
+ +
+ &reftitle.runtime; + &no.config; +
+ +
+ + + diff --git a/reference/quickhash/versions.xml b/reference/quickhash/versions.xml new file mode 100644 index 0000000000..018598af91 --- /dev/null +++ b/reference/quickhash/versions.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +