本文整理汇总了C++中hash_table类的典型用法代码示例。如果您正苦于以下问题:C++ hash_table类的具体用法?C++ hash_table怎么用?C++ hash_table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了hash_table类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lock
void symmetric_hash_join::remove_from_special_cache(
hash_table& table,
int idx,
tuple_ptr tup)
{
boost::interprocess::scoped_lock<boost::interprocess::interprocess_recursive_mutex> lock (m_mutex);
LOG_DEBUG("==>try to remove: " << *tup);
// print_hash_table(left_htable);
std::pair<hash_table::const_iterator, hash_table::const_iterator> range =
table.equal_range((*tup)[idx]);
hash_table::const_iterator to_remove = range.first;
for (; to_remove != range.second; ++to_remove)
{
if ((to_remove->second == tup) &&(to_remove->second->timestamp() == tup->timestamp()))
break;
}
if (to_remove != range.second)
{
table.erase(to_remove);
LOG_DEBUG("\tdrop: " << to_remove->second << " from hash table");
}
}
开发者ID:CCJY,项目名称:engine-1,代码行数:26,代码来源:symmetric_hash_join.cpp
示例2: print_hash_table
void symmetric_hash_join::print_hash_table(hash_table& htable) {
hash_table::iterator it = htable.begin();
for (; it != htable.end(); it++) {
std::pair<boost::any, tuple_ptr> item = *it;
std::cout << "\t" << item.first << " : <" << item.second
<< ">" << std::endl;
}
}
开发者ID:CCJY,项目名称:engine-1,代码行数:9,代码来源:symmetric_hash_join.cpp
示例3: read_and_delta
void read_and_delta (file_reader & reader
, xdelta_stream & stream
, const hash_table & hashes
, std::set<hole_t> & hole_set
, const int blk_len
, bool need_split_hole)
{
bool adddiff = !need_split_hole;
char_buffer<uchar_t> buf (XDELTA_BUFFER_LEN);
typedef std::set<hole_t>::iterator it_t;
std::list<hole_t> holes2remove;
for (it_t begin = hole_set.begin (); begin != hole_set.end (); ++begin) {
const hole_t & hole = *begin;
uint64_t offset = reader.seek_file (hole.offset, FILE_BEGIN);
if (offset != hole.offset) {
std::string errmsg = fmt_string ("Can't seek file %s(%s)."
, reader.get_fname ().c_str (), error_msg ().c_str ());
THROW_XDELTA_EXCEPTION (errmsg);
}
uint32_t buflen = XDELTA_BUFFER_LEN;
uint32_t to_read_bytes = (uint32_t)hole.length;
buflen = to_read_bytes > buflen ? buflen : to_read_bytes;
uchar_t * rdbuf = buf.begin ();
uint32_t size = reader.read_file (rdbuf, buflen);
if (size != buflen) {
std::string errmsg = fmt_string ("Can't read file %s(%s)."
, reader.get_fname ().c_str (), error_msg ().c_str ());
THROW_XDELTA_EXCEPTION (errmsg);
}
to_read_bytes -= size;
const uchar_t * endbuf = rdbuf + size;
rdbuf = buf.begin ();
if ((int32_t)(endbuf - rdbuf) >= blk_len) {
uchar_t * sentrybuf = rdbuf;
rolling_hasher hasher;
hasher.eat_hash (rdbuf, blk_len);
while (true) {
bool newhash = false;
const slow_hash * bsh = hashes.find_block (hasher.hash_value (), rdbuf, blk_len);
uchar_t outchar = 0;
if (bsh) {
// a match was found.
uint32_t slipsize = (uint32_t)(rdbuf - sentrybuf);
if (slipsize > 0 && adddiff)
stream.add_block (sentrybuf, slipsize, offset);
offset += slipsize;
stream.add_block (bsh->tpos, blk_len, offset);
if (need_split_hole) {
hole_t newhole;
newhole.offset = offset;
newhole.length = blk_len;
holes2remove.push_back (newhole);
}
rdbuf += blk_len;
sentrybuf = rdbuf;
newhash = true;
offset += blk_len;
}
else {
// slip the window by one bytes which size is blk_len.
outchar = *rdbuf;
++rdbuf;
}
//
// beyond the buffer.
int remain = (int)(endbuf - rdbuf);
if (remain < blk_len) {
if (to_read_bytes == 0) {
// no more to read.
uint32_t slipsize = (uint32_t)(endbuf - sentrybuf);
if (slipsize > 0 && adddiff)
stream.add_block (sentrybuf, slipsize, offset);
goto end;
}
else {
memmove (buf.begin (), rdbuf, remain);
rdbuf = buf.begin ();
sentrybuf = rdbuf;
buflen = XDELTA_BUFFER_LEN - remain;
buflen = to_read_bytes > buflen ? buflen : to_read_bytes;
size = reader.read_file (rdbuf + remain, buflen);
if (size != buflen) {
std::string errmsg = fmt_string ("Can't read file %s(%s)."
, reader.get_fname ().c_str (), error_msg ().c_str ());
THROW_XDELTA_EXCEPTION (errmsg);
}
//.........这里部分代码省略.........
开发者ID:chen--oRanGe,项目名称:xdeltalib,代码行数:101,代码来源:xdeltalib.cpp
示例4: GCC
void
solaris_elf_asm_comdat_section (const char *name, unsigned int flags, tree decl)
{
const char *signature;
char *section;
comdat_entry entry, **slot;
if (TREE_CODE (decl) == IDENTIFIER_NODE)
signature = IDENTIFIER_POINTER (decl);
else
signature = IDENTIFIER_POINTER (DECL_COMDAT_GROUP (decl));
/* Sun as requires group sections to be fragmented, i.e. to have names of
the form <section>%<fragment>. Strictly speaking this is only
necessary to support cc -xF, but is enforced globally in violation of
the ELF gABI. We keep the section names generated by GCC (generally
of the form .text.<signature>) and append %<signature> to pacify as,
despite the redundancy. */
section = concat (name, "%", signature, NULL);
/* Clear SECTION_LINKONCE flag so targetm.asm_out.named_section only
emits this as a regular section. Emit section before .group
directive since Sun as treats undeclared sections as @progbits,
which conflicts with .bss* sections which are @nobits. */
targetm.asm_out.named_section (section, flags & ~SECTION_LINKONCE, decl);
/* Sun as separates declaration of a group section and of the group
itself, using the .group directive and the #comdat flag. */
fprintf (asm_out_file, "\t.group\t%s," SECTION_NAME_FORMAT ",#comdat\n",
signature, section);
/* Unlike GNU as, group signature symbols need to be defined explicitly
for Sun as. With a few exceptions, this is already the case. To
identify the missing ones without changing the affected frontents,
remember the signature symbols and emit those not marked
TREE_SYMBOL_REFERENCED in solaris_file_end. */
if (!solaris_comdat_htab.is_created ())
solaris_comdat_htab.create (37);
entry.sig = signature;
slot = solaris_comdat_htab.find_slot (&entry, INSERT);
if (*slot == NULL)
{
*slot = XCNEW (comdat_entry);
/* Remember fragmented section name. */
(*slot)->name = section;
/* Emit as regular section, .group declaration has already been done. */
(*slot)->flags = flags & ~SECTION_LINKONCE;
(*slot)->decl = decl;
(*slot)->sig = signature;
}
}
开发者ID:ChillyWillyGuru,项目名称:gcc-4.9.0-PS3,代码行数:53,代码来源:sol2.c
示例5: free
void
lto_orig_address_remove (tree t)
{
struct tree_hash_entry ent;
struct tree_hash_entry **slot;
ent.key = t;
slot = tree_htab.find_slot (&ent, NO_INSERT);
gcc_assert (slot);
free (*slot);
tree_htab.clear_slot (slot);
}
开发者ID:ChillyWillyGuru,项目名称:gcc-4.9.0-PS3,代码行数:12,代码来源:lto-streamer.c
示例6:
/* For given name, return descriptor, create new if needed. */
static struct alloc_pool_descriptor *
allocate_pool_descriptor (const char *name)
{
struct alloc_pool_descriptor **slot;
if (!alloc_pool_hash.is_created ())
alloc_pool_hash.create (10);
slot = alloc_pool_hash.find_slot_with_hash (name,
htab_hash_pointer (name), INSERT);
if (*slot)
return *slot;
*slot = XCNEW (struct alloc_pool_descriptor);
(*slot)->name = name;
return *slot;
}
开发者ID:ChillyWillyGuru,项目名称:gcc-4.9.0-PS3,代码行数:17,代码来源:alloc-pool.c
示例7: XNEW
static struct redirection_data *
lookup_redirection_data (edge e, enum insert_option insert)
{
struct redirection_data **slot;
struct redirection_data *elt;
vec<jump_thread_edge *> *path = THREAD_PATH (e);
/* Build a hash table element so we can see if E is already
in the table. */
elt = XNEW (struct redirection_data);
elt->path = path;
elt->dup_block = NULL;
elt->incoming_edges = NULL;
slot = redirection_data.find_slot (elt, insert);
/* This will only happen if INSERT is false and the entry is not
in the hash table. */
if (slot == NULL)
{
free (elt);
return NULL;
}
/* This will only happen if E was not in the hash table and
INSERT is true. */
if (*slot == NULL)
{
*slot = elt;
elt->incoming_edges = XNEW (struct el);
elt->incoming_edges->e = e;
elt->incoming_edges->next = NULL;
return elt;
}
开发者ID:andikleen,项目名称:gcc,代码行数:34,代码来源:tree-ssa-threadupdate.c
示例8: return
intptr_t
lto_orig_address_get (tree t)
{
struct tree_hash_entry ent;
struct tree_hash_entry **slot;
ent.key = t;
slot = tree_htab.find_slot (&ent, NO_INSERT);
return (slot ? (*slot)->value : 0);
}
开发者ID:ChillyWillyGuru,项目名称:gcc-4.9.0-PS3,代码行数:10,代码来源:lto-streamer.c
示例9:
static tree
TB_up_expr (tree node)
{
tree res;
if (node == NULL_TREE)
return NULL_TREE;
res = TB_up_ht.find (node);
return res;
}
开发者ID:crizeridsdf,项目名称:gcc,代码行数:10,代码来源:tree-browser.c
示例10:
void
lto_orig_address_map (tree t, intptr_t orig_t)
{
struct tree_hash_entry ent;
struct tree_hash_entry **slot;
ent.key = t;
ent.value = orig_t;
slot = tree_htab.find_slot (&ent, INSERT);
gcc_assert (!*slot);
*slot = XNEW (struct tree_hash_entry);
**slot = ent;
}
开发者ID:ChillyWillyGuru,项目名称:gcc-4.9.0-PS3,代码行数:13,代码来源:lto-streamer.c
示例11: if
void
browse_tree (tree begin)
{
tree head;
TB_CODE tbc = TB_UNUSED_COMMAND;
ssize_t rd;
char *input = NULL;
long input_size = 0;
fprintf (TB_OUT_FILE, "\nTree Browser\n");
#define TB_SET_HEAD(N) do { \
vec_safe_push (TB_history_stack, N); \
head = N; \
if (TB_verbose) \
if (head) \
{ \
print_generic_expr (TB_OUT_FILE, head, 0); \
fprintf (TB_OUT_FILE, "\n"); \
} \
} while (0)
TB_SET_HEAD (begin);
/* Store in a hashtable information about previous and upper statements. */
{
TB_up_ht.create (1023);
TB_update_up (head);
}
while (24)
{
fprintf (TB_OUT_FILE, "TB> ");
rd = TB_getline (&input, &input_size, TB_IN_FILE);
if (rd == -1)
/* EOF. */
goto ret;
if (rd != 1)
/* Get a new command. Otherwise the user just pressed enter, and thus
she expects the last command to be reexecuted. */
tbc = TB_get_command (input);
switch (tbc)
{
case TB_UPDATE_UP:
TB_update_up (head);
break;
case TB_MAX:
if (head && (INTEGRAL_TYPE_P (head)
|| TREE_CODE (head) == REAL_TYPE
|| TREE_CODE (head) == FIXED_POINT_TYPE))
TB_SET_HEAD (TYPE_MAX_VALUE (head));
else
TB_WF;
break;
case TB_MIN:
if (head && (INTEGRAL_TYPE_P (head)
|| TREE_CODE (head) == REAL_TYPE
|| TREE_CODE (head) == FIXED_POINT_TYPE))
TB_SET_HEAD (TYPE_MIN_VALUE (head));
else
TB_WF;
break;
case TB_ELT:
if (head && TREE_CODE (head) == TREE_VEC)
{
/* This command takes another argument: the element number:
for example "elt 1". */
TB_NIY;
}
else if (head && TREE_CODE (head) == VECTOR_CST)
{
/* This command takes another argument: the element number:
for example "elt 1". */
TB_NIY;
}
else
TB_WF;
break;
case TB_VALUE:
if (head && TREE_CODE (head) == TREE_LIST)
TB_SET_HEAD (TREE_VALUE (head));
else
TB_WF;
break;
case TB_PURPOSE:
if (head && TREE_CODE (head) == TREE_LIST)
TB_SET_HEAD (TREE_PURPOSE (head));
else
TB_WF;
break;
case TB_IMAG:
//.........这里部分代码省略.........
开发者ID:crizeridsdf,项目名称:gcc,代码行数:101,代码来源:tree-browser.c
注:本文中的hash_table类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论