GRPC Core  9.0.0
Data Structures | Public Types | Public Member Functions | Static Public Member Functions
grpc_core::SliceHashTable< T > Class Template Reference

#include <slice_hash_table.h>

Data Structures

struct  Entry
 

Public Types

typedef int(* ValueCmp) (const T &, const T &)
 

Public Member Functions

 SliceHashTable (size_t num_entries, Entry *entries, ValueCmp value_cmp)
 
virtual ~SliceHashTable ()
 
const T * Get (const grpc_slice &key) const
 Returns the value from the table associated with key. More...
 
- Public Member Functions inherited from grpc_core::RefCounted< SliceHashTable< T > >
 ~RefCounted ()=default
 
RefCountedPtr< SliceHashTable< T > > Ref () GRPC_MUST_USE_RESULT
 
RefCountedPtr< SliceHashTable< T > > Ref (const DebugLocation &location, const char *reason) GRPC_MUST_USE_RESULT
 
void Unref ()
 
void Unref (const DebugLocation &location, const char *reason)
 
bool RefIfNonZero ()
 
bool RefIfNonZero (const DebugLocation &location, const char *reason)
 
 RefCounted (const RefCounted &)=delete
 
RefCountedoperator= (const RefCounted &)=delete
 
- Public Member Functions inherited from grpc_core::PolymorphicRefCount
virtual ~PolymorphicRefCount ()=default
 

Static Public Member Functions

static RefCountedPtr< SliceHashTableCreate (size_t num_entries, Entry *entries, ValueCmp value_cmp)
 Creates a new hash table containing entries, which is an array of length num_entries. More...
 
static int Cmp (const SliceHashTable &a, const SliceHashTable &b)
 Compares a vs. More...
 

Additional Inherited Members

- Protected Member Functions inherited from grpc_core::RefCounted< SliceHashTable< T > >
 RefCounted (TraceFlagT *trace_flag=nullptr, intptr_t initial_refcount=1)
 

Member Typedef Documentation

◆ ValueCmp

template<typename T >
typedef int(* grpc_core::SliceHashTable< T >::ValueCmp) (const T &, const T &)

Constructor & Destructor Documentation

◆ SliceHashTable()

template<typename T >
grpc_core::SliceHashTable< T >::SliceHashTable ( size_t  num_entries,
Entry entries,
ValueCmp  value_cmp 
)

◆ ~SliceHashTable()

template<typename T >
grpc_core::SliceHashTable< T >::~SliceHashTable
virtual

Member Function Documentation

◆ Cmp()

template<typename T >
int grpc_core::SliceHashTable< T >::Cmp ( const SliceHashTable< T > &  a,
const SliceHashTable< T > &  b 
)
static

Compares a vs.

b. A table is considered "smaller" (resp. "greater") if:

  • GPR_ICMP(a->value_cmp, b->value_cmp) < 1 (resp. > 1),
  • else, it contains fewer (resp. more) entries,
  • else, if strcmp(a_key, b_key) < 1 (resp. > 1),
  • else, if value_cmp(a_value, b_value) < 1 (resp. > 1).

◆ Create()

template<typename T >
RefCountedPtr< SliceHashTable< T > > grpc_core::SliceHashTable< T >::Create ( size_t  num_entries,
Entry entries,
ValueCmp  value_cmp 
)
static

Creates a new hash table containing entries, which is an array of length num_entries.

Takes ownership of all keys and values in entries. If not null, value_cmp will be used to compare values in the context of Cmp(). If null, raw pointer (GPR_ICMP) comparison will be used.

◆ Get()

template<typename T >
const T * grpc_core::SliceHashTable< T >::Get ( const grpc_slice key) const

Returns the value from the table associated with key.

Returns null if key is not found.


The documentation for this class was generated from the following file: