| 2504 | template <class Value, class Key, class HashFcn, |
| 2505 | class ExtractKey, class SetKey, class EqualKey, class Alloc> |
| 2506 | class sparse_hashtable |
| 2507 | { |
| 2508 | public: |
| 2509 | typedef Key key_type; |
| 2510 | typedef Value value_type; |
| 2511 | typedef HashFcn hasher; // user provided or spp_hash<Key> |
| 2512 | typedef EqualKey key_equal; |
| 2513 | typedef Alloc allocator_type; |
| 2514 | |
| 2515 | typedef typename allocator_type::size_type size_type; |
| 2516 | typedef typename allocator_type::difference_type difference_type; |
| 2517 | typedef value_type& reference; |
| 2518 | typedef const value_type& const_reference; |
| 2519 | typedef value_type* pointer; |
| 2520 | typedef const value_type* const_pointer; |
| 2521 | |
| 2522 | // Table is the main storage class. |
| 2523 | typedef sparsetable<value_type, allocator_type> Table; |
| 2524 | typedef typename Table::ne_iterator ne_it; |
| 2525 | typedef typename Table::const_ne_iterator cne_it; |
| 2526 | typedef typename Table::destructive_iterator dest_it; |
| 2527 | typedef typename Table::ColIterator ColIterator; |
| 2528 | |
| 2529 | typedef ne_it iterator; |
| 2530 | typedef cne_it const_iterator; |
| 2531 | typedef dest_it destructive_iterator; |
| 2532 | |
| 2533 | // These come from tr1. For us they're the same as regular iterators. |
| 2534 | // ------------------------------------------------------------------- |
| 2535 | typedef iterator local_iterator; |
| 2536 | typedef const_iterator const_local_iterator; |
| 2537 | |
| 2538 | // How full we let the table get before we resize |
| 2539 | // ---------------------------------------------- |
| 2540 | static const int HT_OCCUPANCY_PCT; // = 80 (out of 100); |
| 2541 | |
| 2542 | // How empty we let the table get before we resize lower, by default. |
| 2543 | // (0.0 means never resize lower.) |
| 2544 | // It should be less than OCCUPANCY_PCT / 2 or we thrash resizing |
| 2545 | // ------------------------------------------------------------------ |
| 2546 | static const int HT_EMPTY_PCT; // = 0.4 * HT_OCCUPANCY_PCT; |
| 2547 | |
| 2548 | // Minimum size we're willing to let hashtables be. |
| 2549 | // Must be a power of two, and at least 4. |
| 2550 | // Note, however, that for a given hashtable, the initial size is a |
| 2551 | // function of the first constructor arg, and may be >HT_MIN_BUCKETS. |
| 2552 | // ------------------------------------------------------------------ |
| 2553 | static const size_type HT_MIN_BUCKETS = 4; |
| 2554 | |
| 2555 | // By default, if you don't specify a hashtable size at |
| 2556 | // construction-time, we use this size. Must be a power of two, and |
| 2557 | // at least HT_MIN_BUCKETS. |
| 2558 | // ----------------------------------------------------------------- |
| 2559 | static const size_type HT_DEFAULT_STARTING_BUCKETS = 32; |
| 2560 | |
| 2561 | // iterators |
| 2562 | // --------- |
| 2563 | iterator begin() { return _mk_iterator(table.ne_begin()); } |
nothing calls this directly
no test coverage detected