mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
This commit is contained in:
parent
9f802b2a4d
commit
fe0c22c789
240 changed files with 6823 additions and 6787 deletions
50
src/Dict.cc
50
src/Dict.cc
|
@ -95,11 +95,11 @@ TEST_CASE("dict operation")
|
|||
uint32_t val = 10;
|
||||
uint32_t key_val = 5;
|
||||
|
||||
zeek::detail::HashKey* key = new zeek::detail::HashKey(key_val);
|
||||
detail::HashKey* key = new detail::HashKey(key_val);
|
||||
dict.Insert(key, &val);
|
||||
CHECK(dict.Length() == 1);
|
||||
|
||||
zeek::detail::HashKey* key2 = new zeek::detail::HashKey(key_val);
|
||||
detail::HashKey* key2 = new detail::HashKey(key_val);
|
||||
uint32_t* lookup = dict.Lookup(key2);
|
||||
CHECK(*lookup == val);
|
||||
|
||||
|
@ -120,7 +120,7 @@ TEST_CASE("dict operation")
|
|||
|
||||
uint32_t val2 = 15;
|
||||
uint32_t key_val2 = 25;
|
||||
key2 = new zeek::detail::HashKey(key_val2);
|
||||
key2 = new detail::HashKey(key_val2);
|
||||
|
||||
dict.Insert(key, &val);
|
||||
dict.Insert(key2, &val2);
|
||||
|
@ -141,13 +141,13 @@ TEST_CASE("dict nthentry")
|
|||
|
||||
uint32_t val = 15;
|
||||
uint32_t key_val = 5;
|
||||
zeek::detail::HashKey* okey = new zeek::detail::HashKey(key_val);
|
||||
zeek::detail::HashKey* ukey = new zeek::detail::HashKey(key_val);
|
||||
detail::HashKey* okey = new detail::HashKey(key_val);
|
||||
detail::HashKey* ukey = new detail::HashKey(key_val);
|
||||
|
||||
uint32_t val2 = 10;
|
||||
uint32_t key_val2 = 25;
|
||||
zeek::detail::HashKey* okey2 = new zeek::detail::HashKey(key_val2);
|
||||
zeek::detail::HashKey* ukey2 = new zeek::detail::HashKey(key_val2);
|
||||
detail::HashKey* okey2 = new detail::HashKey(key_val2);
|
||||
detail::HashKey* ukey2 = new detail::HashKey(key_val2);
|
||||
|
||||
unordered.Insert(ukey, &val);
|
||||
unordered.Insert(ukey2, &val2);
|
||||
|
@ -176,16 +176,16 @@ TEST_CASE("dict iteration")
|
|||
|
||||
uint32_t val = 15;
|
||||
uint32_t key_val = 5;
|
||||
zeek::detail::HashKey* key = new zeek::detail::HashKey(key_val);
|
||||
detail::HashKey* key = new detail::HashKey(key_val);
|
||||
|
||||
uint32_t val2 = 10;
|
||||
uint32_t key_val2 = 25;
|
||||
zeek::detail::HashKey* key2 = new zeek::detail::HashKey(key_val2);
|
||||
detail::HashKey* key2 = new detail::HashKey(key_val2);
|
||||
|
||||
dict.Insert(key, &val);
|
||||
dict.Insert(key2, &val2);
|
||||
|
||||
zeek::detail::HashKey* it_key;
|
||||
detail::HashKey* it_key;
|
||||
IterCookie* it = dict.InitForIteration();
|
||||
CHECK(it != nullptr);
|
||||
int count = 0;
|
||||
|
@ -258,7 +258,7 @@ int Dictionary::ThresholdEntries() const
|
|||
return capacity - ( capacity >> detail::DICT_LOAD_FACTOR_BITS );
|
||||
}
|
||||
|
||||
zeek::detail::hash_t Dictionary::FibHash(zeek::detail::hash_t h) const
|
||||
detail::hash_t Dictionary::FibHash(detail::hash_t h) const
|
||||
{
|
||||
//GoldenRatio phi = (sqrt(5)+1)/2 = 1.6180339887...
|
||||
//1/phi = phi - 1
|
||||
|
@ -268,16 +268,16 @@ zeek::detail::hash_t Dictionary::FibHash(zeek::detail::hash_t h) const
|
|||
}
|
||||
|
||||
// return position in dict with 2^bit size.
|
||||
int Dictionary::BucketByHash(zeek::detail::hash_t h, int log2_table_size) const //map h to n-bit
|
||||
int Dictionary::BucketByHash(detail::hash_t h, int log2_table_size) const //map h to n-bit
|
||||
{
|
||||
ASSERT(log2_table_size>=0);
|
||||
if ( ! log2_table_size )
|
||||
return 0; //<< >> breaks on 64.
|
||||
|
||||
#ifdef DICT_NO_FIB_HASH
|
||||
zeek::detail::hash_t hash = h;
|
||||
detail::hash_t hash = h;
|
||||
#else
|
||||
zeek::detail::hash_t hash = FibHash(h);
|
||||
detail::hash_t hash = FibHash(h);
|
||||
#endif
|
||||
|
||||
int m = 64 - log2_table_size;
|
||||
|
@ -619,12 +619,12 @@ void generic_delete_func(void* v)
|
|||
// Look up now also possibly modifies the entry. Why? if the entry is found but not positioned
|
||||
// according to the current dict (so it's before SizeUp), it will be moved to the right
|
||||
// position so next lookup is fast.
|
||||
void* Dictionary::Lookup(const zeek::detail::HashKey* key) const
|
||||
void* Dictionary::Lookup(const detail::HashKey* key) const
|
||||
{
|
||||
return Lookup(key->Key(), key->Size(), key->Hash());
|
||||
}
|
||||
|
||||
void* Dictionary::Lookup(const void* key, int key_size, zeek::detail::hash_t h) const
|
||||
void* Dictionary::Lookup(const void* key, int key_size, detail::hash_t h) const
|
||||
{
|
||||
Dictionary* d = const_cast<Dictionary*>(this);
|
||||
int position = d->LookupIndex(key, key_size, h);
|
||||
|
@ -632,7 +632,7 @@ void* Dictionary::Lookup(const void* key, int key_size, zeek::detail::hash_t h)
|
|||
}
|
||||
|
||||
//for verification purposes
|
||||
int Dictionary::LinearLookupIndex(const void* key, int key_size, zeek::detail::hash_t hash) const
|
||||
int Dictionary::LinearLookupIndex(const void* key, int key_size, detail::hash_t hash) const
|
||||
{
|
||||
for ( int i = 0; i < Capacity(); i++ )
|
||||
if ( ! table[i].Empty() && table[i].Equal((const char*)key, key_size, hash) )
|
||||
|
@ -642,7 +642,7 @@ int Dictionary::LinearLookupIndex(const void* key, int key_size, zeek::detail::h
|
|||
|
||||
// Lookup position for all possible table_sizes caused by remapping. Remap it immediately
|
||||
// if not in the middle of iteration.
|
||||
int Dictionary::LookupIndex(const void* key, int key_size, zeek::detail::hash_t hash, int* insert_position, int* insert_distance)
|
||||
int Dictionary::LookupIndex(const void* key, int key_size, detail::hash_t hash, int* insert_position, int* insert_distance)
|
||||
{
|
||||
ASSERT_VALID(this);
|
||||
if ( ! table )
|
||||
|
@ -696,7 +696,7 @@ int Dictionary::LookupIndex(const void* key, int key_size, zeek::detail::hash_t
|
|||
// position/distance if required. The starting point for the search may not be the bucket
|
||||
// for the current table size since this method is also used to search for an item in the
|
||||
// previous table size.
|
||||
int Dictionary::LookupIndex(const void* key, int key_size, zeek::detail::hash_t hash, int bucket, int end,
|
||||
int Dictionary::LookupIndex(const void* key, int key_size, detail::hash_t hash, int bucket, int end,
|
||||
int* insert_position/*output*/, int* insert_distance/*output*/)
|
||||
{
|
||||
ASSERT(bucket>=0 && bucket < Buckets());
|
||||
|
@ -719,7 +719,7 @@ int Dictionary::LookupIndex(const void* key, int key_size, zeek::detail::hash_t
|
|||
// Insert
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* Dictionary::Insert(void* key, int key_size, zeek::detail::hash_t hash, void* val, bool copy_key)
|
||||
void* Dictionary::Insert(void* key, int key_size, detail::hash_t hash, void* val, bool copy_key)
|
||||
{
|
||||
ASSERT_VALID(this);
|
||||
|
||||
|
@ -880,7 +880,7 @@ void Dictionary::SizeUp()
|
|||
// Remove
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* Dictionary::Remove(const void* key, int key_size, zeek::detail::hash_t hash, bool dont_delete)
|
||||
void* Dictionary::Remove(const void* key, int key_size, detail::hash_t hash, bool dont_delete)
|
||||
{//cookie adjustment: maintain inserts here. maintain next in lower level version.
|
||||
ASSERT_VALID(this);
|
||||
ASSERT(num_iterators == 0 || (cookies && cookies->size() == num_iterators)); //only robust iterators exist.
|
||||
|
@ -1050,7 +1050,7 @@ void Dictionary::StopIterationNonConst(IterCookie* cookie) //const
|
|||
delete cookie;
|
||||
}
|
||||
|
||||
void* Dictionary::NextEntryNonConst(zeek::detail::HashKey*& h, IterCookie*& c, bool return_hash) //const
|
||||
void* Dictionary::NextEntryNonConst(detail::HashKey*& h, IterCookie*& c, bool return_hash) //const
|
||||
{
|
||||
// If there are any inserted entries, return them first.
|
||||
// That keeps the list small and helps avoiding searching
|
||||
|
@ -1072,7 +1072,7 @@ void* Dictionary::NextEntryNonConst(zeek::detail::HashKey*& h, IterCookie*& c, b
|
|||
// and removing from the tail is cheaper.
|
||||
detail::DictEntry e = c->inserted->back();
|
||||
if ( return_hash )
|
||||
h = new zeek::detail::HashKey(e.GetKey(), e.key_size, e.hash);
|
||||
h = new detail::HashKey(e.GetKey(), e.key_size, e.hash);
|
||||
void* v = e.value;
|
||||
c->inserted->pop_back();
|
||||
return v;
|
||||
|
@ -1120,7 +1120,7 @@ void* Dictionary::NextEntryNonConst(zeek::detail::HashKey*& h, IterCookie*& c, b
|
|||
ASSERT(! table[c->next].Empty());
|
||||
void* v = table[c->next].value;
|
||||
if ( return_hash )
|
||||
h = new zeek::detail::HashKey(table[c->next].GetKey(), table[c->next].key_size, table[c->next].hash);
|
||||
h = new detail::HashKey(table[c->next].GetKey(), table[c->next].key_size, table[c->next].hash);
|
||||
|
||||
//prepare for next time.
|
||||
c->next = Next(c->next);
|
||||
|
@ -1134,7 +1134,7 @@ IterCookie* Dictionary::InitForIteration() const
|
|||
return dp->InitForIterationNonConst();
|
||||
}
|
||||
|
||||
void* Dictionary::NextEntry(zeek::detail::HashKey*& h, IterCookie*& cookie, bool return_hash) const
|
||||
void* Dictionary::NextEntry(detail::HashKey*& h, IterCookie*& cookie, bool return_hash) const
|
||||
{
|
||||
Dictionary* dp = const_cast<Dictionary*>(this);
|
||||
return dp->NextEntryNonConst(h, cookie, return_hash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue