本文整理汇总了C++中Hash_new函数的典型用法代码示例。如果您正苦于以下问题:C++ Hash_new函数的具体用法?C++ Hash_new怎么用?C++ Hash_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Hash_new函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LexWriter_init
LexiconWriter*
LexWriter_init(LexiconWriter *self, Snapshot *snapshot, Segment *segment,
PolyReader *polyreader)
{
Schema *schema = PolyReader_Get_Schema(polyreader);
Architecture *arch = Schema_Get_Architecture(schema);
DataWriter_init((DataWriter*)self, snapshot, segment, polyreader);
/* Assign. */
self->index_interval = Arch_Index_Interval(arch);
self->skip_interval = Arch_Skip_Interval(arch);
/* Init. */
self->ix_out = NULL;
self->ixix_out = NULL;
self->dat_out = NULL;
self->count = 0;
self->ix_count = 0;
self->last_tinfo = TInfo_new(0,0,0,0);
self->last_text = CB_new(40);
self->dat_file = CB_new(30);
self->ix_file = CB_new(30);
self->ixix_file = CB_new(30);
self->counts = Hash_new(0);
self->ix_counts = Hash_new(0);
self->stepper = NULL;
self->temp_mode = false;
/* Derive. */
self->stepper = LexStepper_new((CharBuf*)&EMPTY, self->skip_interval);
return self;
}
开发者ID:robertkrimen,项目名称:Search-Kino03,代码行数:34,代码来源:LexiconWriter.c
示例2: DocVec_init
DocVector*
DocVec_init(DocVector *self) {
DocVectorIVARS *const ivars = DocVec_IVARS(self);
ivars->field_bufs = Hash_new(0);
ivars->field_vectors = Hash_new(0);
return self;
}
开发者ID:github188,项目名称:SimpleCode,代码行数:7,代码来源:DocVector.c
示例3: DefDelWriter_Metadata_IMP
Hash*
DefDelWriter_Metadata_IMP(DefaultDeletionsWriter *self) {
DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
DefDelWriter_Metadata_t super_meta
= (DefDelWriter_Metadata_t)SUPER_METHOD_PTR(DEFAULTDELETIONSWRITER,
LUCY_DefDelWriter_Metadata);
Hash *const metadata = super_meta(self);
Hash *const files = Hash_new(0);
for (uint32_t i = 0, max = VA_Get_Size(ivars->seg_readers); i < max; i++) {
SegReader *seg_reader = (SegReader*)VA_Fetch(ivars->seg_readers, i);
if (ivars->updated[i]) {
BitVector *deldocs = (BitVector*)VA_Fetch(ivars->bit_vecs, i);
Segment *segment = SegReader_Get_Segment(seg_reader);
Hash *mini_meta = Hash_new(2);
Hash_Store_Utf8(mini_meta, "count", 5,
(Obj*)Str_newf("%u32", (uint32_t)BitVec_Count(deldocs)));
Hash_Store_Utf8(mini_meta, "filename", 8,
(Obj*)S_del_filename(self, seg_reader));
Hash_Store(files, (Obj*)Seg_Get_Name(segment), (Obj*)mini_meta);
}
}
Hash_Store_Utf8(metadata, "files", 5, (Obj*)files);
return metadata;
}
开发者ID:github188,项目名称:SimpleCode,代码行数:26,代码来源:DeletionsWriter.c
示例4: Hash_load
Hash_T Hash_load(const char *file) {
int fd, read, done = 0, i;
int d[2];
Hash_T h = NULL;
if((fd=File_openRead(file)) != -1) {
h = Hash_new();
while(!done) {
for(i=0; i<2; i++) {
read = File_read(fd, &d[i], sizeof(int));
if(read == -1)
goto err;
else if(read == 0)
done = 1;
else
Hash_add(h, d[0], d[1]);
}
}
}
return h;
err:
Hash_free(&h);
return Hash_new();
}
开发者ID:QubeX2,项目名称:mangolib,代码行数:25,代码来源:hash.c
示例5: LexWriter_init
LexiconWriter*
LexWriter_init(LexiconWriter *self, Schema *schema, Snapshot *snapshot,
Segment *segment, PolyReader *polyreader)
{
Architecture *arch = Schema_Get_Architecture(schema);
DataWriter_init((DataWriter*)self, schema, snapshot, segment, polyreader);
// Assign.
self->index_interval = Arch_Index_Interval(arch);
self->skip_interval = Arch_Skip_Interval(arch);
// Init.
self->ix_out = NULL;
self->ixix_out = NULL;
self->dat_out = NULL;
self->count = 0;
self->ix_count = 0;
self->dat_file = CB_new(30);
self->ix_file = CB_new(30);
self->ixix_file = CB_new(30);
self->counts = Hash_new(0);
self->ix_counts = Hash_new(0);
self->temp_mode = false;
self->term_stepper = NULL;
self->tinfo_stepper = (TermStepper*)MatchTInfoStepper_new(schema);
return self;
}
开发者ID:gitpan,项目名称:KinoSearch,代码行数:29,代码来源:LexiconWriter.c
示例6: testNew
static void testNew()
{
Hash_T h0 = Hash_new(0);
EXPECT_NOT_NULL(h0);
Hash_T h1 = Hash_new(1);
EXPECT_NOT_NULL(h1);
Hash_T h2 = Hash_new(2);
EXPECT_NOT_NULL(h2);
}
开发者ID:rlowrance,项目名称:re,代码行数:11,代码来源:Hash-test.c
示例7: testFree
static void testFree()
{
Hash_T h0 = Hash_new(0);
Hash_free(&h0);
EXPECT_NULL(h0);
Hash_T h1 = Hash_new(1);
Hash_free(&h1);
EXPECT_NULL(h1);
Hash_T h2 = Hash_new(2);
Hash_free(&h2);
EXPECT_NULL(h2);
}
开发者ID:rlowrance,项目名称:re,代码行数:14,代码来源:Hash-test.c
示例8: FullTextType_Dump_For_Schema_IMP
Hash*
FullTextType_Dump_For_Schema_IMP(FullTextType *self) {
FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
Hash *dump = Hash_new(0);
Hash_Store_Utf8(dump, "type", 4, (Obj*)Str_newf("fulltext"));
// Store attributes that override the defaults.
if (ivars->boost != 1.0) {
Hash_Store_Utf8(dump, "boost", 5, (Obj*)Str_newf("%f64", ivars->boost));
}
if (!ivars->indexed) {
Hash_Store_Utf8(dump, "indexed", 7, (Obj*)CFISH_FALSE);
}
if (!ivars->stored) {
Hash_Store_Utf8(dump, "stored", 6, (Obj*)CFISH_FALSE);
}
if (ivars->sortable) {
Hash_Store_Utf8(dump, "sortable", 8, (Obj*)CFISH_TRUE);
}
if (ivars->highlightable) {
Hash_Store_Utf8(dump, "highlightable", 13, (Obj*)CFISH_TRUE);
}
return dump;
}
开发者ID:apache,项目名称:lucy,代码行数:25,代码来源:FullTextType.c
示例9: testInsert
static void testInsert()
{
// test general case
Hash_T h0 = Hash_new(0);
EXPECT_EQ_UINT32(0, h0->nElements);
EXPECT_EQ_UINT32(0, h0->tableSize);
int key1 = 123;
char* value1 = "1";
h0 = Hash_insert(h0, Atom_newFromInt64(key1), value1);
EXPECT_NOT_NULL(h0);
EXPECT_EQ_UINT32(1, h0->nElements);
EXPECT_EQ_UINT32(1, h0->tableSize);
int key2 = -27;
char value2[] = "value2";
h0 = Hash_insert(h0, Atom_newFromInt64(key2), value2);
EXPECT_NOT_NULL(h0);
EXPECT_EQ_UINT32(2, h0->nElements);
EXPECT_EQ_UINT32(3, h0->tableSize);
char * key3 = "abc";
int16_t value3 = 1056;
Str_T s = Str_newFromInt16(value3);
h0 = Hash_insert(h0, Atom_newFromString(key3), Str_str(s));
EXPECT_NOT_NULL(h0);
EXPECT_EQ_UINT32(3, h0->nElements);
EXPECT_EQ_UINT32(3, h0->tableSize);
Str_free(&s);
Hash_free(&h0);
EXPECT_NULL(h0);
}
开发者ID:rlowrance,项目名称:re,代码行数:33,代码来源:Hash-test.c
示例10: S_make_dump
// Create a test data structure including at least one each of Hash, Vector,
// and String.
static Obj*
S_make_dump() {
Hash *dump = Hash_new(0);
Hash_Store_Utf8(dump, "foo", 3, (Obj*)Str_newf("foo"));
Hash_Store_Utf8(dump, "stuff", 5, (Obj*)Vec_new(0));
return (Obj*)dump;
}
开发者ID:rectang,项目名称:lucy,代码行数:9,代码来源:TestJson.c
示例11: test_Dump_and_Load
static void
test_Dump_and_Load(TestBatch *batch) {
Hash *hash = Hash_new(0);
Obj *dump;
Hash *loaded;
Hash_Store_Str(hash, "foo", 3,
(Obj*)CB_new_from_trusted_utf8("foo", 3));
dump = (Obj*)Hash_Dump(hash);
loaded = (Hash*)Obj_Load(dump, dump);
TEST_TRUE(batch, Hash_Equals(hash, (Obj*)loaded),
"Dump => Load round trip");
DECREF(dump);
DECREF(loaded);
/* TODO: Fix Hash_Load().
Hash_Store_Str(hash, "_class", 6,
(Obj*)CB_new_from_trusted_utf8("not_a_class", 11));
dump = (Obj*)Hash_Dump(hash);
loaded = (Hash*)Obj_Load(dump, dump);
TEST_TRUE(batch, Hash_Equals(hash, (Obj*)loaded),
"Load still works with _class if it's not a real class");
DECREF(dump);
DECREF(loaded);
*/
DECREF(hash);
}
开发者ID:pavansondur,项目名称:lucy,代码行数:31,代码来源:TestHash.c
示例12: DataWriter_Metadata_IMP
Hash*
DataWriter_Metadata_IMP(DataWriter *self) {
Hash *metadata = Hash_new(0);
Hash_Store_Utf8(metadata, "format", 6,
(Obj*)Str_newf("%i32", DataWriter_Format(self)));
return metadata;
}
开发者ID:apache,项目名称:lucy,代码行数:7,代码来源:DataWriter.c
示例13: S_make_dump
// Create a test data structure including at least one each of Hash, VArray,
// and CharBuf.
static Obj*
S_make_dump() {
Hash *dump = Hash_new(0);
Hash_Store_Str(dump, "foo", 3, (Obj*)CB_newf("foo"));
Hash_Store_Str(dump, "stuff", 5, (Obj*)VA_new(0));
return (Obj*)dump;
}
开发者ID:pavansondur,项目名称:lucy,代码行数:9,代码来源:TestJson.c
示例14: SnowStop_gen_stoplist
Hash*
SnowStop_gen_stoplist(String *language) {
char lang[2];
lang[0] = tolower(Str_Code_Point_At(language, 0));
lang[1] = tolower(Str_Code_Point_At(language, 1));
const uint8_t **words = NULL;
if (memcmp(lang, "da", 2) == 0) { words = SnowStop_snow_da; }
else if (memcmp(lang, "de", 2) == 0) { words = SnowStop_snow_de; }
else if (memcmp(lang, "en", 2) == 0) { words = SnowStop_snow_en; }
else if (memcmp(lang, "es", 2) == 0) { words = SnowStop_snow_es; }
else if (memcmp(lang, "fi", 2) == 0) { words = SnowStop_snow_fi; }
else if (memcmp(lang, "fr", 2) == 0) { words = SnowStop_snow_fr; }
else if (memcmp(lang, "hu", 2) == 0) { words = SnowStop_snow_hu; }
else if (memcmp(lang, "it", 2) == 0) { words = SnowStop_snow_it; }
else if (memcmp(lang, "nl", 2) == 0) { words = SnowStop_snow_nl; }
else if (memcmp(lang, "no", 2) == 0) { words = SnowStop_snow_no; }
else if (memcmp(lang, "pt", 2) == 0) { words = SnowStop_snow_pt; }
else if (memcmp(lang, "ru", 2) == 0) { words = SnowStop_snow_ru; }
else if (memcmp(lang, "sv", 2) == 0) { words = SnowStop_snow_sv; }
else {
return NULL;
}
size_t num_stopwords = 0;
for (uint32_t i = 0; words[i] != NULL; i++) { num_stopwords++; }
Hash *stoplist = Hash_new(num_stopwords);
for (uint32_t i = 0; words[i] != NULL; i++) {
char *word = (char*)words[i];
String *stop = Str_new_wrap_trusted_utf8(word, strlen(word));
Hash_Store(stoplist, stop, (Obj*)CFISH_TRUE);
DECREF(stop);
}
return (Hash*)stoplist;
}
开发者ID:carriercomm,项目名称:lucy,代码行数:33,代码来源:SnowballStopFilter.c
示例15: Schema_init
Schema*
Schema_init(Schema *self) {
SchemaIVARS *const ivars = Schema_IVARS(self);
// Init.
ivars->analyzers = Hash_new(0);
ivars->types = Hash_new(0);
ivars->sims = Hash_new(0);
ivars->uniq_analyzers = Vec_new(2);
Vec_Resize(ivars->uniq_analyzers, 1);
// Assign.
ivars->arch = Schema_Architecture(self);
ivars->sim = Arch_Make_Similarity(ivars->arch);
return self;
}
开发者ID:lazycrazyowl,项目名称:lucy,代码行数:16,代码来源:Schema.c
示例16: Schema_Dump_IMP
Hash*
Schema_Dump_IMP(Schema *self) {
SchemaIVARS *const ivars = Schema_IVARS(self);
Hash *dump = Hash_new(0);
Hash *type_dumps = Hash_new(Hash_Get_Size(ivars->types));
// Record class name, store dumps of unique Analyzers.
Hash_Store_Utf8(dump, "_class", 6,
(Obj*)Str_Clone(Schema_get_class_name(self)));
Hash_Store_Utf8(dump, "analyzers", 9,
Freezer_dump((Obj*)ivars->uniq_analyzers));
// Dump FieldTypes.
Hash_Store_Utf8(dump, "fields", 6, (Obj*)type_dumps);
HashIterator *iter = HashIter_new(ivars->types);
while (HashIter_Next(iter)) {
String *field = HashIter_Get_Key(iter);
FieldType *type = (FieldType*)HashIter_Get_Value(iter);
Class *type_class = FType_get_class(type);
// Dump known types to simplified format.
if (type_class == FULLTEXTTYPE) {
FullTextType *fttype = (FullTextType*)type;
Hash *type_dump = FullTextType_Dump_For_Schema(fttype);
Analyzer *analyzer = FullTextType_Get_Analyzer(fttype);
uint32_t tick
= S_find_in_array(ivars->uniq_analyzers, (Obj*)analyzer);
// Store the tick which references a unique analyzer.
Hash_Store_Utf8(type_dump, "analyzer", 8,
(Obj*)Str_newf("%u32", tick));
Hash_Store(type_dumps, field, (Obj*)type_dump);
}
else if (type_class == STRINGTYPE || type_class == BLOBTYPE) {
Hash *type_dump = FType_Dump_For_Schema(type);
Hash_Store(type_dumps, field, (Obj*)type_dump);
}
// Unknown FieldType type, so punt.
else {
Hash_Store(type_dumps, field, FType_Dump(type));
}
}
DECREF(iter);
return dump;
}
开发者ID:lazycrazyowl,项目名称:lucy,代码行数:47,代码来源:Schema.c
示例17: S_zero_out
static void
S_zero_out(Snapshot *self)
{
DECREF(self->entries);
DECREF(self->path);
self->entries = Hash_new(0);
self->path = NULL;
}
开发者ID:gitpan,项目名称:KinoSearch,代码行数:8,代码来源:Snapshot.c
示例18: RAMFolder_init
RAMFolder*
RAMFolder_init(RAMFolder *self, const CharBuf *path)
{
Folder_init((Folder*)self, path);
self->elems = Hash_new(16);
if (CB_Get_Size(self->path) != 0) S_read_fsfolder(self);
return self;
}
开发者ID:robertkrimen,项目名称:Search-Kino03,代码行数:8,代码来源:RAMFolder.c
示例19: S_zero_out
static void
S_zero_out(Snapshot *self) {
SnapshotIVARS *const ivars = Snapshot_IVARS(self);
DECREF(ivars->entries);
DECREF(ivars->path);
ivars->entries = Hash_new(0);
ivars->path = NULL;
}
开发者ID:zilent1,项目名称:udesc-pra-rafael-lucy,代码行数:8,代码来源:Snapshot.c
示例20: S_zero_out
static void
S_zero_out(Snapshot *self)
{
DECREF(self->entries);
DECREF(self->filename);
self->entries = Hash_new(0);
self->filename = NULL;
}
开发者ID:robertkrimen,项目名称:Search-Kino03,代码行数:8,代码来源:Snapshot.c
注:本文中的Hash_new函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论