本文整理汇总了C++中KEY类的典型用法代码示例。如果您正苦于以下问题:C++ KEY类的具体用法?C++ KEY怎么用?C++ KEY使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KEY类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smove
bool xRedisClient::smove(const RedisDBIdx& dbi, const KEY& srckey, const KEY& deskey, const VALUE& member) {
if (0 == srckey.length()) {
return false;
}
SETDEFAULTIOTYPE(MASTER);
return command_bool(dbi, "SMOVE %s", srckey.c_str(), deskey.c_str(), member.c_str());
}
示例2: spop
bool xRedisClient::spop(const RedisDBIdx& dbi, const KEY& key, VALUE& member) {
if (0 == key.length()) {
return false;
}
SETDEFAULTIOTYPE(MASTER);
return command_string(dbi, member, "SPOP %s", key.c_str());
}
示例3: smembers
bool xRedisClient::smembers(const RedisDBIdx& dbi, const KEY& key, VALUES& vValue) {
if (0 == key.length()) {
return false;
}
SETDEFAULTIOTYPE(SLAVE);
return command_list(dbi, vValue, "SMEMBERS %s", key.c_str());
}
示例4: greedy
void KMplex::greedy(KEY& T, KEY& S)
{
while(T.size() > 0)
{
S.push_back(T.back());
T.pop_back();
}
return;
}
示例5: srandmember
bool xRedisClient::srandmember(const RedisDBIdx& dbi, const KEY& key, VALUES& members, int count) {
if (0 == key.length()) {
return false;
}
SETDEFAULTIOTYPE(SLAVE);
if (0 == count) {
return command_list(dbi, members, "SRANDMEMBER %s", key.c_str());
}
return command_list(dbi, members, "SRANDMEMBER %s %d", key.c_str(), count);
}
示例6: difference
// Returns list of key values of x NOT in y (i.e. set_difference)
const KEY difference(const KEY& x, const KEY& y)
{
KEY difference;
KEY::const_iterator xi = x.begin(), yi = y.begin();
for(; xi != x.end(); ++xi)
{
if(*xi == *yi) // Found yi in x, move to next yi to look for;
++yi;
else
difference.push_back(*xi);
}
return difference;
}
示例7: sample
// Returns systematic sample of k-th value of x, where k is determined
// by the fraction argument (k = 1/f).
const KEY sample(const KEY& x, const double fraction)
{
KEY sample;
double interval = 1.0 / fraction;
// Randomly select starting location on interval [0, m]
// where m ~ interval size.
unsigned m = (unsigned)ceil(interval);
double location = uniform((unsigned)0, m);
for(; location < x.size() - 1; location += interval)
{
// For non-integer locations, round up to next integer value k
unsigned k = (unsigned)ceil(location);
// Take k-th sample
sample.push_back(x[k]);
}
return sample;
}
示例8: srem
bool xRedisClient::srem(const RedisDBIdx& dbi, const KEY& key, const VALUES& vmembers, int64_t& count) {
if (0 == key.length()) {
return false;
}
SETDEFAULTIOTYPE(MASTER);
VDATA vCmdData;
vCmdData.push_back("SREM");
vCmdData.push_back(key);
addparam(vCmdData, vmembers);
return commandargv_integer(dbi, vCmdData, count);
}
示例9: finalize_sub_plan
void Locality_Splitter::finalize_sub_plan (
Deployment::DeploymentPlan &sub_plan,
KEY &sub_plan_key)
{
DANCEX11_LOG_TRACE ("Locality_Splitter::finalize_sub_plan");
// check for availability of LocalityManager instance
if (!sub_plan_key.has_locality_manager ())
{
// add minimal default LocalityManager instance to sub plan
uint32_t impl_index = sub_plan.implementation ().size ();
sub_plan.implementation ().push_back (::Deployment::MonolithicDeploymentDescription ());
uint32_t inst_index = sub_plan.instance ().size ();
sub_plan.instance ().push_back (::Deployment::InstanceDeploymentDescription ());
sub_plan.instance ().back ().implementationRef (impl_index);
// set correct implementation type
Deployment::Property exec_property;
exec_property.name (IMPL_TYPE);
exec_property.value () <<= DANCE_LOCALITYMANAGER;
sub_plan.implementation ().back ().execParameter ().push_back (exec_property);
// create unique name for Locality Manager
ACE_Utils::UUID uuid;
ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (uuid);
std::string lm_name ("Locality Manager [");
lm_name += uuid.to_string ()->c_str ();
lm_name += "]";
sub_plan.instance ().back ().name (lm_name);
DANCEX11_LOG_TRACE ("Locality_Splitter::finalize_sub_plan - " <<
"No locality manager found, created a default locality named<" <<
sub_plan.instance ().back ().name () << ">");
// add instance to sub plan key
sub_plan_key.add_instance (inst_index);
// mark as locality manager
sub_plan_key.locality_manager_instance (
sub_plan_key.instances ().size () - 1);
}
}
示例10: merge
void KMplex::merge(KEY& S, KEY& T)
{
for(KEY::iterator s = S.begin(); s != S.end(); ++s)
T.push_back(*s);
}
示例11: srandmember
bool xRedisClient::srandmember(const RedisDBIdx& dbi, const KEY& key, VALUES& members, int count) {
if (0==count) {
return command_list(dbi, members, "SRANDMEMBER %s", key.c_str());
}
return command_list(dbi, members, "SRANDMEMBER %s %d", key.c_str(), count);
}
示例12: operator
bool operator()( const KEY& lhs, const KEY& rhs ) const
{
boost::shared_ptr<KEY::element_type> shared_lhs = lhs.lock();
boost::shared_ptr<KEY::element_type> shared_rhs = rhs.lock();
return *shared_lhs < *shared_rhs;
}
示例13: X
void KMplex::resample()
{
std::cout << "KMplex::resample" << std::endl;
// Build dissimilarity matrix for clustered data X
const MATRIX& X(*(kmeans_->X_));
D_.resize(X.rows(), X.rows());
std::cout << "\nKMplex: (Allocation rule: "
<< (unsigned)alloc_ << ")" << std::endl;
for(unsigned i = 0; i < kmeans_->K(); ++i)
{
const KMeans::Cluster& cluster(kmeans_->cluster(i));
if(cluster.size() > 0)
{
unsigned NTr = trainingQuota(cluster);
unsigned NTe = testingQuota(cluster);
unsigned NVa = validatingQuota(cluster);
std::cout << "Cluster (" << i << ") N: " << cluster.size() <<
" NTr: " << NTr <<
" NTe: " << NTe <<
" NVa: " << NVa << std::endl;
// Calculate intra-cluster distances
KEY indices = kmeans_->cluster(i).indices();
for(KEY::iterator a = indices.begin(); a != indices.end(); ++a)
for(KEY::iterator b = a + 1; b != indices.end(); ++b)
{
D_[*a][*b] = euclidean(X[*a], X[*b]);
D_[*b][*a] = D_[*a][*b];
}
// Initialise samples
KEY training, testing, validating;
if(NTr > 0)
initialise(indices, training);
if(NTe > 0)
initialise(indices, testing);
if(NVa > 0)
initialise(indices, validating);
// Sample remaining points using Duplex sampling
while(indices.size() > 0)
{
if(training.size() < NTr)
sample(indices, training);
if(testing.size() < NTe)
sample(indices, testing);
if(validating.size() < NVa)
sample(indices, validating);
}
// Add intra-cluster samples to respective global samples
if(training.size() > 0)
merge(training, trainingKey_);
if(testing.size() > 0)
merge(testing, testingKey_);
if(validating.size() > 0)
merge(validating, validatingKey_);
}
}
allocate(trainingKey_, training_);
allocate(testingKey_, testing_);
allocate(validatingKey_, validating_);
}
示例14: spop
bool xRedisClient::spop(const RedisDBIdx& dbi, const KEY& key, VALUE& member) {
return command_string(dbi, member, "SPOP %s", key.c_str());
}
示例15: smember
bool xRedisClient::smember(const RedisDBIdx& dbi, const KEY& key, VALUES& vValue) {
return command_list(dbi, vValue, "SMEMBER %s", key.c_str());
}