+ this->strings_.clear();
+ this->key_to_offset_.clear();
+ this->string_set_.clear();
+}
+
+template<typename Stringpool_char>
+Stringpool_template<Stringpool_char>::~Stringpool_template()
+{
+ this->clear();
+}
+
+// Resize the internal hashtable with the expectation we'll get n new
+// elements. Note that the hashtable constructor takes a "number of
+// buckets you'd like," rather than "number of elements you'd like,"
+// but that's the best we can do.
+
+template<typename Stringpool_char>
+void
+Stringpool_template<Stringpool_char>::reserve(unsigned int n)
+{
+ this->key_to_offset_.reserve(n);
+
+#if defined(HAVE_UNORDERED_MAP)
+ this->string_set_.rehash(this->string_set_.size() + n);
+ return;
+#elif defined(HAVE_TR1_UNORDERED_MAP)
+ // rehash() implementation is broken in gcc 4.0.3's stl
+ //this->string_set_.rehash(this->string_set_.size() + n);
+ //return;
+#elif defined(HAVE_EXT_HASH_MAP)
+ this->string_set_.resize(this->string_set_.size() + n);
+ return;
+#endif
+
+ // This is the generic "reserve" code, if no #ifdef above triggers.
+ String_set_type new_string_set(this->string_set_.size() + n);
+ new_string_set.insert(this->string_set_.begin(), this->string_set_.end());
+ this->string_set_.swap(new_string_set);
+}
+
+// Compare two strings of arbitrary character type for equality.
+
+template<typename Stringpool_char>
+bool
+Stringpool_template<Stringpool_char>::string_equal(const Stringpool_char* s1,
+ const Stringpool_char* s2)
+{
+ while (*s1 != 0)
+ if (*s1++ != *s2++)
+ return false;
+ return *s2 == 0;
+}
+
+// Specialize string_equal for char.
+
+template<>
+inline bool
+Stringpool_template<char>::string_equal(const char* s1, const char* s2)
+{
+ return strcmp(s1, s2) == 0;
+}
+
+// Equality comparison function for the hash table.
+
+template<typename Stringpool_char>
+inline bool
+Stringpool_template<Stringpool_char>::Stringpool_eq::operator()(
+ const Hashkey& h1,
+ const Hashkey& h2) const
+{
+ return (h1.hash_code == h2.hash_code
+ && h1.length == h2.length
+ && (h1.string == h2.string
+ || memcmp(h1.string, h2.string,
+ h1.length * sizeof(Stringpool_char)) == 0));