当前位置: 首页>>代码示例>>C++>>正文


C++ StringData::hash方法代码示例

本文整理汇总了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());
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:7,代码来源:zend_array.cpp

示例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;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:34,代码来源:zend_array.cpp

示例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);
}
开发者ID:TingoZhou,项目名称:hiphop-php,代码行数:28,代码来源:immutable_map.cpp

示例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;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:12,代码来源:zend_array.cpp

示例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;
}
开发者ID:RepmujNetsik,项目名称:hiphop-php,代码行数:12,代码来源:vector_array.cpp

示例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;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:15,代码来源:zend_array.cpp

示例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);
  }
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:15,代码来源:zend_array.cpp

示例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;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:23,代码来源:zend_array.cpp


注:本文中的StringData::hash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。