本文整理汇总了C++中PointPtr::getDims方法的典型用法代码示例。如果您正苦于以下问题:C++ PointPtr::getDims方法的具体用法?C++ PointPtr::getDims怎么用?C++ PointPtr::getDims使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointPtr
的用法示例。
在下文中一共展示了PointPtr::getDims方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
void Cluster::add(const PointPtr &p)
{
if (points != NULL)
assert(p->getDims() == points->p->getDims()); //make sure dimensions match
if (find(p) != NULL) { //make sure p is not already in cluster
return;
}
size++;
LNodePtr node = new LNode; // Dynamically allocate new node
LNodePtr ptr = points;
node->p = p;
if (points == NULL) { //case: empty cluster
points = node;
node->next = nullptr;
return;
}
if (*node->p < *points->p) { //case: new point is smallest point
node->next = points;
points = node;
return;
}
LNodePtr last = nullptr;
while ( *p > *ptr->p) { //put in lexographic order
last = ptr;
if (ptr->next == NULL) {//if end of list
node->next = nullptr;
last->next = node;
return;
}
ptr = ptr->next;
}
while (*p == *ptr->p && p > ptr->p) { //if points are equal sort by memory address
last = ptr; //for reasons of comparison
if (ptr->next == NULL) {
node->next = nullptr;
last->next = node;
return;
}
ptr = ptr->next;
}
node->next = ptr;
if (last != nullptr)
last->next = node;
else
points = node;
}