randaasealedA sealed, reference counted hash table implementation that uses randomized probing for collision resolution. This struct has the following advantages over D's builtin associative arrays:
1. Deterministic, ref counted freeing of memory, which is important for huge AAs or very memory-tight systems.
2. Plays nicely with conservative GC. Keys, values and hashes are in separate arrays, meaning that they don't all get GC scanned just because one needs to be GC scanned. This also saves on alignment overhead.
3. The implementation is based on parallel arrays, and allows for space to be reserved such that a certain number of elements can be added with a guarantee of no reallocation. Because of this, insertions are much faster for large arrays and don't interfere with multithreading.
4. The linear congruential probing retains its O(1) expected lookup time as long as there are minimal collisions in full (32- or 64-bit) hash space, regardless of how many collisions there are in modulus hash space.
The main disadvantages are:
1. The combination of parallel arrays and randomized probing wreaks havoc on cache performance, meaning lookups are somewhat slower than with the builtin AA.
2. The worst-case lookup time is unbounded, though this is more theoretical trivia than a practical issue (except maybe in high security situations where a hash table is not the proper data structre anyhow). The distribution of lookup times is geometric, meaning that large lookup times are extremely improbable.
Finding good linear congruential parameters for 64-bit size_t/hash_t.
Copyright (C) 2009-2010 David Simcha
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|Page was generated with on Sat Jan 29 16:27:34 2011|