本文整理汇总了C++中SLNode类的典型用法代码示例。如果您正苦于以下问题:C++ SLNode类的具体用法?C++ SLNode怎么用?C++ SLNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SLNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SLNode
void SLList::Insert(int data)
{
SLNode* insert = new SLNode(data); //assigns data to new node
SLNode* current = head_; //assigns head to current
SLNode* prev = current;
if(!head_ || data <= current->contents()) //if there is a list or data is less than or equal to head_
{
InsertHead(data);
}
else if(data > tail_->contents()) //if data is greater than tail
{
InsertTail(data);
}
else
{
while(current->contents() < data) //while current is less than data
{
prev = current; //we assign prev to currents position
current = current->next_node(); //then assign current to next position
}
insert->set_next_node(current); //set node at currents position
prev->set_next_node(insert); //set data at proper position
size_++;
}
}
开发者ID:JordanLaney,项目名称:CSCI21,代码行数:26,代码来源:sl_list.cpp
示例2: insertHead
//New node addition to list
void SList::insertHead(int newNodeContent){
SLNode *n;
n = new SLNode;
n->setNextNode(NULL);
n->setContents(newNodeContent);
n->setNextNode(head);
head = n;
//SLNode *n = new SLNode();
//n->setContents(newNodeContent);
//n->setNextNode(head);
//head = n;
size++;
}
开发者ID:austinbossetti,项目名称:CSCI-21-FALL-2015,代码行数:16,代码来源:SList.cpp
示例3: while
/*!
SLGroup::buildAABB() loops over all child nodes and merges their AABB
to the axis aligned bounding box of the group.
*/
SLAABBox& SLGroup::buildAABB()
{ SLNode* current = _first;
// empty the groups AABB
_aabb.minWS(SLVec3f( FLT_MAX, FLT_MAX, FLT_MAX));
_aabb.maxWS(SLVec3f(-FLT_MAX,-FLT_MAX,-FLT_MAX));
while (current)
{ _aabb.merge(current->buildAABB());
current = current->next();
}
_aabb.fromWStoOS(_aabb.minWS(), _aabb.maxWS(), _wmI);
return _aabb;
}
开发者ID:heweitykc,项目名称:opengl,代码行数:19,代码来源:SLGroup.cpp
示例4: toString
string SList::toString() const {
stringstream ss;
if (head == NULL) {
ss.str("");
} else {
int i = 1;
for (SLNode* n = head; n != NULL; n = n->getNextNode()) {
ss << n->getContents();
if (i < size)
ss << ",";
i++;
}
}
return ss.str();
}
开发者ID:SC-Carlito831,项目名称:CSCI-21-FALL-2015,代码行数:15,代码来源:SList.cpp
示例5: shapeInit
/*!
SLGroup::shapeInit loops over all child nodes and calls their init method with
an incremented depth. While looping it must be checked that all child nodes
have a depth equal the groups depth + 1.
*/
void SLGroup::shapeInit(SLSceneView* sv)
{ SLNode* current = _first;
while (current)
{ if (current->depth() && current->depth() != depth()+1)
{ SL_EXIT_MSG("Scenegraph is not directed acyclic. There is a loop.");
}
current->init(sv, depth()+1);
// Set transparent flags of the group
if (!_aabb.hasAlpha() && ((SLShape*)current)->aabb()->hasAlpha())
_aabb.hasAlpha(true);
current = current->next();
}
}
开发者ID:heweitykc,项目名称:opengl,代码行数:20,代码来源:SLGroup.cpp
示例6: dequeue
Object* SLQueue::dequeue() {
if (isEmpty())
return NULL;
SLNode* rem = head;
head = head->getNext();
Object* retval = rem->getData();
rem->setData(NULL);
rem->setNext(NULL);
delete rem;
size--;
return retval;
}
开发者ID:efgm1024,项目名称:ADT_C,代码行数:15,代码来源:SLQueue.cpp
示例7: insertHead
void SList::insertTail (int contents) {
if (head == NULL) {
insertHead(contents);
}
else {
SLNode* i = head;
SLNode* newNode = new SLNode(contents);
while (i->getNextNode() != NULL) {
i = i->getNextNode();
}
i->setNextNode(newNode);
++numNodes;
}
}
开发者ID:mattsbmws,项目名称:CSCI-21-SPRING-2014,代码行数:15,代码来源:SList.cpp
示例8: while
SLNode* SList::getTail() const {
SLNode* currentNode = mHead;
if(currentNode != 0) {
while(true) {
SLNode* const nextNode = currentNode->getNextNode();
if(nextNode == 0) {
return currentNode;
}
currentNode = nextNode;
}
}
return currentNode;
}
开发者ID:GreatBigBore,项目名称:Bishop-Rob,代码行数:16,代码来源:SList.cpp
示例9: toString
string SList::toString () const {
stringstream listStream;
SLNode* current;
current = head;
if (head == NULL){
cout << "" << endl;
} else {
while (current != NULL) {
listStream << current->getContents() << ",";
current = current->getNextNode();
}
}
return(listStream.str().substr(0,listStream.str().length() - 1));
}
开发者ID:codingkitty81,项目名称:CSCI-21-FALL-2015,代码行数:16,代码来源:SList.cpp
示例10: assert
/*!
SLGroup::intersect loops over all child nodes of the group and calls their
intersect method.
*/
SLbool SLGroup::shapeHit(SLRay* ray)
{ assert(ray != 0);
SLNode* current = _first;
SLbool wasHit = false;
while (current)
{
// do not test origin node for shadow rays
if (!(current==ray->originShape && ray->type==SHADOW))
{ if (current->hit(ray) && !wasHit) wasHit = true;
}
if (ray->isShaded()) return true;
current = current->next();
}
return wasHit;
}
开发者ID:heweitykc,项目名称:opengl,代码行数:21,代码来源:SLGroup.cpp
示例11: ToString
/**
* returns a string representation of the contents
* of all nodes in the list, in the format
* NUM1, NUM2, ..., LASTNUM
* returns the empty string on an empty list (i.e. returns "")
*/
string SLList::ToString() const
{
if (head_ == NULL)
return "";
stringstream ss;
SLNode* temp = head_;
while (temp != NULL)
{
ss << temp->contents();
if (temp->next_node() != NULL)
ss << ", ";
temp = temp->next_node();
}
return ss.str();
}
开发者ID:Dminer001,项目名称:CSCI-21,代码行数:24,代码来源:sl_list.cpp
示例12: if
void SList::removeTail () {
if(head == NULL){
}
else if (head->getNextNode()==NULL) {
removeHead();
} else {
SLNode* i = head;
SLNode* j=NULL;
while (i->getNextNode() !=NULL) {
j=i;
i=i->getNextNode();
}
delete i;
j->setNextNode(NULL);
size--;
}
}
开发者ID:sesanjmcdonald,项目名称:CSCI-21-FALL-2015-,代码行数:18,代码来源:SList.cpp
示例13: removeTail
void SList::removeTail () {
if (head != NULL) {
if (head->getNextNode() == NULL) {
delete head;
head = NULL;
} else {
SLNode* nextToTail = head;
SLNode* tail = head->getNextNode();
while (tail->getNextNode() != NULL) {
nextToTail = tail;
tail = tail->getNextNode();
}
delete tail;
nextToTail->setNextNode(NULL);
}
size--;
}
}
开发者ID:codingkitty81,项目名称:CSCI-21-FALL-2015,代码行数:18,代码来源:SList.cpp
示例14: SLNode
void SList::insertTail (int newContents)
{
SLNode* newNode = new SLNode(newContents);
SLNode* temp = head;
if(head == NULL)
{
head = newNode;
}
else
{
while(temp->getNextNode() != NULL)
{
temp = temp -> getNextNode();
}
temp -> setNextNode(newNode);
}
size++;
}
开发者ID:staylor014,项目名称:CSCI-21-SPRING-2014,代码行数:18,代码来源:SList.cpp
示例15: insertHead
void SList::insertTail(int value)
{
if(head == NULL)
{
insertHead(value);
}
else
{
SLNode* newNode = new SLNode(value);
SLNode* temp = head;
while(temp->getNextNode() != NULL)
{
temp = temp->getNextNode();
}
temp->setNextNode(newNode);
size++;
}
}// create a new SLNode and attach at the end of list
开发者ID:Trongard,项目名称:-CSCI-21-SPRING-2014,代码行数:18,代码来源:SList.cpp
示例16: removeTail
void SList::removeTail () {
if (head != NULL) {
SLNode* i = head;
SLNode* trailer = NULL;
while (i->getNextNode() != NULL) {
trailer = i;
i = i->getNextNode();
}
delete i;
--numNodes;
if (trailer == NULL) {
head = NULL;
}
else {
trailer->setNextNode(NULL);
}
}
}
开发者ID:mattsbmws,项目名称:CSCI-21-SPRING-2014,代码行数:19,代码来源:SList.cpp
示例17: toString
string SList::toString()
{
stringstream list;
SLNode* temp = head;
if(head == NULL)
{
return list.str();
}
else
{
while(temp->getNextNode() != NULL)
{
list << temp->getContents() << ",";
temp = temp->getNextNode();
}
list << temp->getContents();
}
return list.str();
}
开发者ID:staylor014,项目名称:CSCI-21-SPRING-2014,代码行数:19,代码来源:SList.cpp
示例18: while
void SList::insertTail (int contents){
if(head != NULL) {
//Finds the tail.
SLNode* i = head;
while (i->getNextNode() != NULL) {
//Starts at head and moves it over to the last node.
i = i->getNextNode();
}
SLNode* node = new SLNode(contents);
//points at the end and inserts the new node that was just created.
i->setNextNode(node);
size++;
} else {
//Empty list - make it to insert head as it's the same thing.
insertHead(contents);
}
}
开发者ID:rkgilbert10,项目名称:CSCI-21-FALL-2015,代码行数:19,代码来源:SList.cpp
示例19: SLNode
/*!
Copies the nodes meshes and children recursively.
*/
SLNode* SLNode::copyRec()
{
SLNode* copy = new SLNode(name());
copy->_om = _om;
copy->_depth = _depth;
copy->_isAABBUpToDate = _isAABBUpToDate;
copy->_isAABBUpToDate = _isWMUpToDate;
copy->_drawBits = _drawBits;
copy->_aabb = _aabb;
if (_animation)
copy->_animation = new SLAnimation(*_animation);
else copy->_animation = 0;
for (auto mesh : _meshes) copy->addMesh(mesh);
for (auto child : _children) copy->addChild(child->copyRec());
return copy;
}
开发者ID:h3ll5ur7er,项目名称:SLProject,代码行数:22,代码来源:SLNode.cpp
示例20: RemoveHead
/**
* removes the tail node from the list,
* or does nothing if the list is empty
*/
void SLList::RemoveTail()
{
if (head_ != NULL)
{
if (head_ == tail_)
{
RemoveHead();
} else
{
SLNode* temp = head_;
while (temp->next_node() != tail_)
temp = temp->next_node();
temp->set_next_node(NULL);
delete tail_;
tail_ = temp;
size_ -= 1;
}
}
}
开发者ID:Dminer001,项目名称:CSCI-21,代码行数:23,代码来源:sl_list.cpp
注:本文中的SLNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论