本文整理汇总了C++中StringData::hash方法的典型用法代码示例。如果您正苦于以下问题:C++ StringData::hash方法的具体用法?C++ StringData::hash怎么用?C++ StringData::hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringData
的用法示例。
在下文中一共展示了StringData::hash方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exists
bool ZendArray::exists(CVarRef k) const {
TypedValueAccessor tva = k.getTypedAccessor();
if (isIntKey(tva)) return find(getIntKey(tva));
ASSERT(k.isString());
StringData *key = getStringKey(tva);
return find(key->data(), key->size(), key->hash());
}
示例2: copyImpl
ArrayData *ZendArray::append(const ArrayData *elems, ArrayOp op, bool copy) {
if (UNLIKELY(copy)) {
ZendArray *a = copyImpl();
a->append(elems, op, false);
return a;
}
if (op == Plus) {
for (ArrayIter it(elems); !it.end(); it.next()) {
Variant key = it.first();
CVarRef value = it.secondRef();
if (key.isNumeric()) {
addValWithRef(key.toInt64(), value);
} else {
addValWithRef(key.getStringData(), value);
}
}
} else {
ASSERT(op == Merge);
for (ArrayIter it(elems); !it.end(); it.next()) {
Variant key = it.first();
CVarRef value = it.secondRef();
if (key.isNumeric()) {
nextInsertWithRef(value);
} else {
Variant *p;
StringData *sd = key.getStringData();
addLvalImpl(sd, sd->hash(), &p, true);
p->setWithRef(value);
}
}
}
return NULL;
}
示例3: add
HOT_FUNC
void ImmutableMap::add(int pos, CVarRef key, CVarRef val, bool unserializeObj) {
int64_t ikey;
StringData* skey;
int32_t hash;
Bucket* b = buckets() + pos;
switch (key.getType()) {
case KindOfInt64: {
hash = ikey = key.toInt64();
b->setIntKey(ikey);
break;
}
case KindOfString: {
skey = StringData::GetStaticString(key.getStringData());
goto static_case;
}
case KindOfStaticString: {
skey = key.getStringData();
static_case:
hash = skey->hash();
b->setStrKey(skey, hash);
break;
}
default: not_reached();
}
addVal(pos, hash & m.m_capacity_mask, val, unserializeObj);
}
示例4: get
CVarRef ZendArray::get(CStrRef k, bool error /* = false */) const {
StringData *key = k.get();
int64 prehash = key->hash();
Bucket *p = find(key->data(), key->size(), prehash);
if (p) {
return p->data;
}
if (error) {
raise_notice("Undefined index: %s", k.data());
}
return null_variant;
}
示例5: lval
ArrayData *VectorArray::lval(CVarRef k, Variant *&ret, bool copy,
bool checkExist /* = false */) {
Variant::TypedValueAccessor tva = k.getTypedAccessor();
if (isIntKey(tva)) {
return VectorArray::lval(getIntKey(tva), ret, copy, checkExist);
}
ASSERT(k.isString());
ZendArray *a = escalateToZendArray();
StringData *sd = getStringKey(tva);
a->addLvalImpl(sd, sd->hash(), &ret);
return a;
}
示例6: getIndex
ssize_t ZendArray::getIndex(CVarRef k) const {
Bucket *p;
TypedValueAccessor tva = k.getTypedAccessor();
if (isIntKey(tva)) {
p = find(getIntKey(tva));
} else {
ASSERT(k.isString());
StringData *key = getStringKey(tva);
p = find(key->data(), key->size(), key->hash());
}
if (p) {
return (ssize_t)p;
}
return ArrayData::invalid_index;
}
示例7: load
void ZendArray::load(CVarRef k, Variant &v) const {
Bucket *p;
TypedValueAccessor tva = k.getTypedAccessor();
if (isIntKey(tva)) {
p = find(getIntKey(tva));
} else {
ASSERT(k.isString());
StringData *strkey = getStringKey(tva);
int64 prehash = strkey->hash();
p = find(strkey->data(), strkey->size(), prehash);
}
if (p) {
v.setWithRef(p->data);
}
}
示例8: addLvalImpl
ArrayData *ZendArray::lval(CStrRef k, Variant *&ret, bool copy,
bool checkExist /* = false */) {
StringData *key = k.get();
int64 prehash = key->hash();
if (!copy) {
addLvalImpl(key, prehash, &ret);
return NULL;
}
if (!checkExist) {
ZendArray *a = copyImpl();
a->addLvalImpl(key, prehash, &ret);
return a;
}
Bucket *p = find(key->data(), key->size(), prehash);
if (p &&
(p->data.isReferenced() || p->data.isObject())) {
ret = &p->data;
return NULL;
}
ZendArray *a = copyImpl();
a->addLvalImpl(key, prehash, &ret, p);
return a;
}