4 #ifndef IBIS_DICTIONARY_H
5 #define IBIS_DICTIONARY_H
9 #if defined(HAVE_UNORDERED_MAP)
10 #include <unordered_map>
11 #elif defined(__GNUC__) && (__GNUC__+0 <= 4 || ( __GNUC__+0 == 4 && __GNUC_MINOR__+0 <= 5))
12 #include <backward/hash_map>
14 #include <unordered_map>
19 template <>
struct hash< const char* > {
20 size_t operator()(
const char* x)
const;
43 class FASTBIT_CXX_DLLSPEC
ibis::dictionary {
45 ~dictionary() {
clear();}
47 dictionary(
const dictionary& dic);
51 uint32_t
size()
const {
return raw_.size();}
53 const char* operator[](uint32_t i)
const;
54 uint32_t operator[](
const char* str)
const;
55 const char*
find(
const char* str)
const;
58 uint32_t insert(
const char*, uint32_t);
59 uint32_t insert(
const char*);
60 uint32_t insertRaw(
char*);
61 uint32_t appendOrdered(
const char*);
66 int read(
const char*);
67 int write(
const char*)
const;
69 int fromASCII(std::istream &);
70 void toASCII(std::ostream &)
const;
91 #if defined(HAVE_UNORDERED_MAP)
93 #elif defined(__GNUC__) && (__GNUC__+0 <= 4 || ( __GNUC__+0 == 4 && __GNUC_MINOR__+0 <= 5))
102 int readRaw(
const char*, FILE *);
103 int readKeys0(
const char*, FILE *);
104 int readKeys1(
const char*, FILE *);
105 int readKeys2(
const char*, FILE *);
106 void mergeBuffers()
const;
127 return (i < raw_.size() ? raw_[i] :
static_cast<const char*
>(0));
136 const uint32_t ind = operator[](str);
137 if (ind < raw_.size())
141 #endif // IBIS_DICTIONARY_H
const char * find(const char *str) const
Find the given string in the dictionary.
Definition: dict-0.h:92
int64_t write(int, const void *, int64_t)
A wrapper over POSIX write function.
Definition: util.cpp:999
const char * operator[](uint32_t i) const
Return a string corresponding to the integer.
Definition: dict-0.h:84
Definition: dictionary.h:19
size_t find(const std::vector< T > &, const T &, size_t)
Find the first position where the value is no less than val.
Definition: utilidor.cpp:3795
void swap(array_t< T > &rhs)
Swap the content of two array_t objects.
Definition: array_t.h:184
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
std::unordered_map< const char *, uint32_t, std::hash< const char * >, std::equal_to< const char * > > MYMAP
Member variable key_ contains the hash_map that connects a string value to an integer.
Definition: dictionary.h:99
int copy(const char *to, const char *from)
Copy file named "from" to a file named "to".
Definition: util.cpp:894
array_t< const char * > key_
Member variable key_ contains the string values in alphabetic order.
Definition: dict-0.h:58
uint32_t size() const
Return the number of entries in the dictionary.
Definition: dictionary.h:51
int64_t read(int, void *, int64_t)
A wrapper over POSIX read function.
Definition: util.cpp:973
void clear(ibis::array_t< ibis::bitvector * > &bv)
Clear an array of bit vectors.
Definition: bitvector.cpp:4662
array_t< const char * > raw_
Member variable raw_ contains the string values in the order of the code assignment.
Definition: dict-0.h:56
void swap(dictionary &)
Swap the content of two dictionaries.
Definition: dict-0.h:74
array_t< char * > buffer_
Member varaible buffer_ contains a list of pointers to the memory that holds the strings.
Definition: dict-0.h:64
Provide a dual-directional mapping between strings and integers.
Definition: dict-0.h:19