本文整理汇总了C++中GiSTlist::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ GiSTlist::Append方法的具体用法?C++ GiSTlist::Append怎么用?C++ GiSTlist::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GiSTlist
的用法示例。
在下文中一共展示了GiSTlist::Append方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadNode
// split this M-tree into a list of trees having height level, which is used in the "splitting" phase of the BulkLoad algorithm
// nCreated is the number of created subtrees,
// level is the split level for the tree,
// children is the list of the parents of each subtree,
// name is the root for the subtrees names
// the return value is the list of splitted subtrees's names
GiSTlist<char *> *
MT::SplitTree (int *nCreated, int level, GiSTlist<MTentry *> *parentEntries, const char *name)
{
GiSTlist<MTnode *> *oldList = new GiSTlist<MTnode *>; // upper level nodes
MTnode *node = new MTnode; // this is because the first operation on node is a delete
GiSTpath path;
path.MakeRoot ();
oldList->Append((MTnode *) ReadNode(path)); // insert the root
do { // build the roots list
GiSTlist<MTnode *> *newList = new GiSTlist<MTnode *>; // lower level nodes
while (!oldList->IsEmpty()) {
delete node; // delete the old node created by ReadNode
node = oldList->RemoveFront(); // retrieve next node to be examined
path = node->Path();
for (int i=0; i<node->NumEntries(); i++) { // append all its children to the new list
path.MakeChild ((*node)[i].Ptr()->Ptr());
newList->Append((MTnode *)ReadNode(path));
path.MakeParent ();
}
}
delete oldList;
oldList = newList;
} while (node->Level() > level); // stop if we're at the split level
delete node;
GiSTlist<char *> *newTreeNames = new GiSTlist<char *>; // this is the results list
while (!oldList->IsEmpty()) { // now append each sub-tree to its root
char newName[50];
sprintf (newName, "%s.%i", name, ++(*nCreated));
unlink (newName); // if this M-tree already exists, delete it
MT *newTree = new MT;
newTree->Create(newName); // create a new M-tree
path.MakeRoot ();
MTnode *rootNode = (MTnode *) newTree->ReadNode(path); // read the root of the new tree
node = oldList->RemoveFront();
newTree->Append(rootNode, (MTnode *)node->Copy()); // append the current node to the root of new tree
parentEntries->Append(node->ParentEntry()); // insert the original parent entry into the list
newTreeNames->Append(strdup(newName)); // insert the new M-tree name into the list
delete node;
delete rootNode;
delete newTree;
}
delete oldList;
return newTreeNames;
}
示例2: ReadNode
void
MT::CollectStats ()
{
GiSTpath path;
path.MakeRoot ();
GiSTnode *node = ReadNode (path);
if (!node->IsLeaf()) {
int maxLevel = node->Level();
double *radii = new double[maxLevel];
int *pages = new int[maxLevel];
for (int i=0; i<maxLevel; i++) {
pages[i] = 0;
radii[i] = 0;
}
TruePredicate truePredicate;
GiSTlist<GiSTentry*> list = node->Search(truePredicate); // retrieve all the entries in this node
double overlap = ((MTnode *)node)->Overlap();
double totalOverlap = overlap;
delete node;
while (!list.IsEmpty()) {
GiSTentry *entry = list.RemoveFront ();
path.MakeChild (entry->Ptr());
node = ReadNode (path);
overlap = ((MTnode *)node)->Overlap();
totalOverlap += overlap;
pages[node->Level()]++;
radii[node->Level()] += ((MTkey *) entry->Key())->MaxRadius();
GiSTlist<GiSTentry*> newlist;
if (!node->IsLeaf()) {
newlist = node->Search(truePredicate); // recurse to next level
}
while (!newlist.IsEmpty()) {
list.Append (newlist.RemoveFront ());
}
path.MakeParent ();
delete entry;
delete node;
}
// output the results
cout << "Level:\tPages:\tAverage_Radius:"<<endl;
int totalPages = 1; // for the root
for (int i=maxLevel-1; i>=0; i--) {
totalPages += pages[i];
cout << i << ":\t" << pages[i] << "\t" << radii[i]/pages[i] << endl;
}
cout << "TotalPages:\t" << totalPages << endl;
cout << "LeafPages:\t" << pages[0] << endl;
cout << "TotalOverlap:\t" << (float)totalOverlap << endl;
delete []radii;
delete []pages;
} else {
delete node;
}
}
示例3:
GiSTlist<GiSTentry*>
GiSTnode::Search(const GiSTpredicate &query) const
{
GiSTlist<GiSTentry*> list;
for (int i=0; i<numEntries; i++) {
GiSTentry *e = (*this)[i];
if (query.Consistent(*e))
list.Append((GiSTentry*)e->Copy());
}
return list;
}
示例4:
GiSTlist<GiSTentry*>
GiST::RemoveTop(GiSTnode *node)
{
GiSTlist<GiSTentry*> deleted;
int count=node->NumEntries();
// default: remove the first ones on the page
int num_rem=(int)((count+1)*RemoveRatio()+0.5);
for(int i=num_rem-1; i>=0; i--) {
deleted.Append((GiSTentry *)(*node)[i].Ptr()->Copy());
node->DeleteEntry(i);
}
return(deleted);
}
示例5:
GiSTlist<MTentry *>
MTnode::RangeSearch(const MTquery &query)
{
GiSTlist<MTentry *> result;
if(IsLeaf())
for(int i=0; i<NumEntries(); i++) {
MTentry *e=(MTentry *)(*this)[i].Ptr()->Copy();
MTquery *q=(MTquery *)query.Copy();
if(q->Consistent(*e)) { // object qualifies
e->setmaxradius(q->Grade());
result.Append(e);
}
else delete e;
delete q;
}
else
for(int i=0; i<NumEntries(); i++) {
MTentry *e=(MTentry *)(*this)[i].Ptr();
MTquery *q=(MTquery *)query.Copy();
if(q->Consistent(*e)) { // sub-tree not excluded
GiSTpath childpath=Path();
MTnode *child;
GiSTlist<MTentry *>list;
childpath.MakeChild(e->Ptr());
child=(MTnode *)((MT *)Tree())->ReadNode(childpath);
list=child->RangeSearch(*q); // recurse the search
while(!list.IsEmpty()) result.Append(list.RemoveFront());
delete child;
}
delete q;
}
return result;
}
示例6: Path
GiSTlist<MTentry *>
MTnode::RangeSearch (const MTquery &query)
{
GiSTlist<MTentry *> results;
if (IsLeaf()) {
for (int i=0; i<NumEntries(); i++) {
MTentry *entry = (MTentry *) (*this)[i].Ptr()->Copy();
MTquery *newQuery = (MTquery *) query.Copy();
if (newQuery->Consistent(*entry)) { // object qualifies
entry->SetMaxRadius(newQuery->Grade());
results.Append (entry);
} else {
delete entry;
}
delete newQuery;
}
} else {
for (int i=0; i<NumEntries(); i++) {
MTentry *entry = (MTentry *) (*this)[i].Ptr();
MTquery *newQuery = (MTquery *) query.Copy();
if (newQuery->Consistent(*entry)) { // sub-tree included
GiSTpath childPath = Path ();
childPath.MakeChild (entry->Ptr());
MTnode *childNode = (MTnode *) ((MT *)Tree())->ReadNode(childPath);
GiSTlist<MTentry *> childResults = childNode->RangeSearch(*newQuery); // recurse the search
while (!childResults.IsEmpty()) {
results.Append (childResults.RemoveFront());
}
delete childNode;
}
delete newQuery;
}
}
return results;
}
示例7: qsort
GiSTlist<GiSTentry*>
RT::RemoveTop(GiSTnode *node)
{
GiSTlist<GiSTentry*> deleted;
int count = node->NumEntries();
int num_rem = (int)((count + 1)*RemoveRatio() + 0.5);
distix *dvec = new distix[node->NumEntries()];
int *ivec = new int[num_rem];
RTentry *uentry = (RTentry *)(node->Union());
RTkey tmpbox;
int i;
// compute distance of each node to center of bounding box,
// and sort by decreasing distance
for (i = 0; i < node->NumEntries(); i++) {
dvec[i].ix = i;
tmpbox = ((RTentry *)((*node)[i].Ptr()))->bbox();
dvec[i].dist = tmpbox.dist(uentry->bbox());
}
delete uentry;
qsort(dvec, node->NumEntries(), sizeof(distix), GiSTdistixcmp);
for (i = 0; i < num_rem; i++)
ivec[i] = dvec[i].ix;
delete dvec;
// sort the first num_rem by index number to make removal easier
qsort(ivec, num_rem, sizeof(int), GiSTintcmp);
for (i = num_rem - 1; i >=0 ; i--) {
RTentry *tmpentry = new RTentry(*(RTentry *)((*node)[ivec[i]].Ptr()));
deleted.Append(tmpentry);
node->DeleteEntry(ivec[i]);
}
delete ivec;
return(deleted);
}
示例8: main
//.........这里部分代码省略.........
if(nearest) pred=new Pred(*obj);
else {
MTpred *npred=new Pred(*obj);
pred=new NotPred(npred);
delete npred;
}
// eps=atof(argv[1]);
TopQuery query(pred, k);
delete pred;
if(!gist) CommandOpen("mtree", "graphs.M3");
CommandNearest(query);
CommandClose();
delete obj;
}
else if(!strcmp(cmdLine, "cursor")) {
MTobject *obj=Read();
Pred pred(*obj);
if(!gist) CommandOpen("mtree", "graphs.M3");
MTcursor cursor(*gist, pred);
scanf("%s", cmdLine);
while(strcmp(cmdLine, "close")) {
if(!strcmp(cmdLine, "next")) {
int k;
GiSTlist<MTentry *> list;
scanf("%s", cmdLine);
k=atoi(cmdLine);
// std::cout << "Fetching next " << k << " entries...\n";
for(; k>0; k--) list.Append(cursor.Next());
while(!list.IsEmpty()) {
MTentry *e=list.RemoveFront();
// std::cout << e;
delete e;
objs++;
}
}
scanf("%s", cmdLine);
}
delete obj;
CommandClose();
}
/* else if(!strcmp(cmdLine, "find")) {
int n, k, l, oldcompdists, oldIOread, oldobjs;
scanf("%s", cmdLine);
n=atoi(cmdLine);
double **x=(double **)calloc(n, sizeof(double *));
for(i=0; i<n; i++) x[i]=(double *)calloc(dimension, sizeof(double));
MTpred **p=(MTpred **)calloc(n, sizeof(MTpred *));
AndPred **ap=(AndPred **)calloc(n-1, sizeof(AndPred *));
for(i=0; i<n; i++) {
for(int j=0; j<dimension; j++) {
scanf("%s", cmdLine);
x[i][j]=atof(cmdLine);
}
if(x[i][0]>=0) {
MTobject obj(x[i]);
// std::cout << "obj=" << obj << std::endl;
p[i]=new Pred(obj);
示例9: EntrySize
//.........这里部分代码省略.........
// assign each entry to its nearest parent
for (int i=0; i<n; i++) {
if (bSampled[i]) {
int j = 0;
for (; samples[j]!=i; j++); // find this entry in the samples set and return position in it
lists[j].Prepend (i); // insert the entry in the right sample
dists[j].Prepend (0); // distance between sample and data[i]
sizes[j] += addEntrySize + data[i]->CompressedLength();
} else { // here we optimize the distance computations (like we do in the insert algorithm)
double *dist = new double[s]; // distance between this non-sample and samples
dist[0] = data[samples[0]]->object().distance(data[i]->object());
int minIndex = 0;
for (int j=1; j<s; j++) { // seek the nearest sample
dist[j] = -MaxDist();
if (fabs (data[samples[j]]->Key()->distance - data[i]->Key()->distance) >= dist[minIndex]) { // pruning
continue;
}
BOOL flag = TRUE;
for (int k=0; k<j && flag; k++) { // pruning (other samples)
if (dist[k] < 0) {
continue;
} else {
flag = fabs (dist[k] - distm[j].front->entry[k]) < dist[minIndex];
}
}
if (!flag) {
continue;
}
dist[j] = data[samples[j]]->object().distance(data[i]->object()); // have to compute this distance
if (dist[j] < dist[minIndex]) {
minIndex = j;
}
}
lists[minIndex].Append (i); // insert the entry in the right sample
dists[minIndex].Append (dist[minIndex]); // distance between sample and data[i]
sizes[minIndex] += addEntrySize + data[i]->CompressedLength();
ns[minIndex]++;
sizes[minIndex] >= MINSIZE ? delete []dist : distm[minIndex].Append (dist); // correspond with lists
}
}
// redistribute underfilled parents
int i;
while (sizes[i = FindMin (sizes, nSamples)] < MINSIZE) {
GiSTlist<int> list = lists[i]; // each sample set
while (!dists[i].IsEmpty()) { // clear distance between each sample and its members
dists[i].RemoveFront ();
}
// substitute this set with last set
for (int j=0; j<nSamples; j++) {
for (GiSTlistnode<double *> *node=distm[j].front; node; node=node->next) {
node->entry[i] = node->entry[nSamples-1];
}
}
GiSTlist<double *> dlist = distm[i]; // relative distances between sample[i] and other samples, reposition by myself
distm[i] = distm[nSamples-1];
lists[i] = lists[nSamples-1];
dists[i] = dists[nSamples-1];
samples[i] = samples[nSamples-1];
sizes[i] = sizes[nSamples-1];
ns[i] = ns[nSamples-1];
nSamples--;
while (!list.IsEmpty()) { // assign each entry to its nearest parent
double *dist = dlist.RemoveFront (); // relative distances between sample[i] (old) and other samples (old)