本文整理汇总了C++中set::GetElement方法的典型用法代码示例。如果您正苦于以下问题:C++ set::GetElement方法的具体用法?C++ set::GetElement怎么用?C++ set::GetElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类set
的用法示例。
在下文中一共展示了set::GetElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sfexcl_split
//.........这里部分代码省略.........
SIGNED_4B_TYPE nspnts = 0;
apvector<SIGNED_4B_TYPE> pnts_i(N), pnts(N - C), spnts(N), vecRneibs;
for (Z1 = Z = 0; Z < SIGNED_4B_TYPE(N); Z++)
{
if (seed.IsInSet(Z)) continue;
pnts[Z1++] = Z;
}
pnts.rand_shuffle(); //randomize datapoint positions
for (Z = 0; Z < SIGNED_4B_TYPE(N - C); Z++) pnts_i[pnts[Z]] = Z; //store randomized positions
while (C < N)
{//go on as long as there are points to exhaust
if (seed.IsEmpty())
{
if ( ((Mode & SFEXCL_NEXTSF_RAND) == SFEXCL_NEXTSF_RAND) || (nspnts == 0) )
//get random seeding point from the rest of the data
Z = 0; //GetRandomNumber( N - C ); //array has been randomized already anyway
else
{//el would store -> pnts[]
mnD = 0;
if ((Mode & SFEXCL_NEXTSF_STEP2_MIN) == SFEXCL_NEXTSF_STEP2_MIN) mnD = distMax * N;
if ((Mode & SFEXCL_NEXTSF_SPHERES) == SFEXCL_NEXTSF_SPHERES)
for (el = Z = 0; Z + C < N; Z++)
{
rtD = 0;
if ( ((Mode & SFEXCL_NEXTSF_STEP1_SUMDIST) != SFEXCL_NEXTSF_STEP1_SUMDIST) &&
((Mode & SFEXCL_NEXTSF_STEP1_MIN) == SFEXCL_NEXTSF_STEP1_MIN) )
rtD = distMax * N;
for (Z1 = 0; Z1 < nspnts; Z1++)
{
if ((Mode & SFEXCL_NEXTSF_STEP1_SUMDIST) == SFEXCL_NEXTSF_STEP1_SUMDIST)
rtD += dist(pnts[Z], spnts[Z1]);
else
if ( ((Mode & SFEXCL_NEXTSF_STEP1_MIN) == SFEXCL_NEXTSF_STEP1_MIN) ^ (dist(pnts[Z], spnts[Z1]) > rtD) )
rtD = dist(pnts[Z], spnts[Z1]);
}
if ( ((Mode & SFEXCL_NEXTSF_STEP2_MIN) == SFEXCL_NEXTSF_STEP2_MIN) ^ ( mnD < rtD ) )
{
mnD = rtD;
el = Z;
}
}
else //if ((Mode & SFEXCL_NEXTSF_SPHERES) == SFEXCL_NEXTSF_SPHERES)
for (Z = 0; Z < nspnts; Z++)
{
el1 = 0;
for (Z1 = 1; Z1 + C < N; Z1++)
if ( ((Mode & SFEXCL_NEXTSF_STEP1_MIN) == SFEXCL_NEXTSF_STEP1_MIN) ^
(dist(spnts[Z], pnts[Z1]) > dist(spnts[Z], pnts[el1])) )
el1 = Z1;
if ( ((Mode & SFEXCL_NEXTSF_STEP2_MIN) == SFEXCL_NEXTSF_STEP2_MIN) ^ ( mnD < dist(spnts[Z], pnts[el1]) ) )
{
mnD = dist(spnts[Z], pnts[el1]);
el = el1;
}
}
Z = el;
}//if ((Mode & SFEXCL_NEXTSF_RAND) == SFEXCL_NEXTSF_RAND) .. else
el = pnts[Z];
train.PutInSet(el);
C++;
pnts[Z] = pnts[N - C];
pnts_i[el] = N;
pnts_i[pnts[Z]] = Z;
}//if (seed.IsEmpty())
else
{
seed.GetElement(el);
seed.RemoveFromSet(el);
}
spnts[nspnts++] = el;
//now let's get the points within R-distance from el and distribute them between train and test
Rneibs[el].GetList(vecRneibs);
vecRneibs.rand_shuffle(); //to randomize the order of points!
for (Z1 = el1 = 0; el1 < vecRneibs.length(); el1++)
{
Z = vecRneibs[el1];
if (test.IsInSet(Z) || train.IsInSet(Z)) continue;
C++;
pnts[pnts_i[Z]] = pnts[N - C];
pnts_i[pnts[N - C]] = pnts_i[Z];
pnts_i[Z] = N;
if ((Mode & SFEXCL_SPLIT_FIRST2TRN) == SFEXCL_SPLIT_FIRST2TRN)
{
if (Z1++ < toTrain) train.PutInSet(Z); else test.PutInSet(Z);
}
else
if (Z1++ < toTest) test.PutInSet(Z); else train.PutInSet(Z);
if (Z1 == toTrain + toTest) Z1 = 0;
}
}//global-loop while (C < N)
return (R);
}