本文整理汇总了C++中SLNode::getNext方法的典型用法代码示例。如果您正苦于以下问题:C++ SLNode::getNext方法的具体用法?C++ SLNode::getNext怎么用?C++ SLNode::getNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SLNode
的用法示例。
在下文中一共展示了SLNode::getNext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
/*Insertar:
a) Si la lista esta vacia
b) Si se inserta al frente
c) Si se inserta al medio*/
bool SLinkedList::insert(Object* data,int pos){
if(pos < 0 || pos > ssize)
return false;
SLNode* neo = new SLNode(data);
if(!neo)
return false;
if(isEmpty()){
head = neo;
}else{
if(pos == 0){
neo->setNext(head);
head = neo;
}else{
SLNode* tmpn = head;
for(int i = 0; i < pos-1; i++){
tmpn = tmpn->getNext();
}
neo->setNext(tmpn->getNext());
tmpn->setNext(neo);
if(pos == ssize)
neo->setNext(NULL);
}
}
ssize++;
return true;
}
示例2: remove
Object* SLinkedList::remove(unsigned int pos){
if(isEmpty()){
return NULL;
}
if(pos < 0 || pos > ssize){
return NULL;
}
SLNode* neo = head;
Object* retVal = NULL;
if(pos == 0){
head = head->getNext();
}else{
for(int i = 0; i < pos-1; i++){
neo = neo->getNext();
}
SLNode* tmpn = neo;
neo = neo->getNext();
tmpn->setNext(neo->getNext());
}
retVal = neo->getData();
neo->setData(NULL);
neo->setNext(NULL);
delete neo;
ssize--;
return retVal;
}
示例3: print
void SLinkedList::print()const{
if(!(isEmpty())){
SLNode* tmpn = head;
for(int i = 0; i < ssize; i++){
tmpn->getData()->print();
tmpn = tmpn->getNext();
}
}
}
示例4: last
Object* SLinkedList::last()const{
if(isEmpty()){
return NULL;
}
SLNode* tmpn = head;
for(int i = 0; i < ssize-1; i++){
tmpn = tmpn->getNext();
}
return tmpn->getData();
}
示例5: get
Object* SLinkedList::get(unsigned int pos)const{
if(isEmpty()){
return NULL;
}
if(pos < 0 && pos >= ssize){
return NULL;
}
SLNode* tmpn = head;
for(int i = 0; i < pos; i++){
tmpn = tmpn->getNext();
}
return tmpn->getData();
}
示例6: indexOf
int SLinkedList::indexOf(Object* data)const{
if(isEmpty()){
return -1;
}
SLNode* tmpn = head;
for(int i = 0; i < ssize; i++){
if(tmpn->getData()->equals(data)){
return i;
}
tmpn = tmpn->getNext();
}
return -1;
}
示例7: queue
bool SLQueue::queue(Object* E) {
SLNode* neo = new SLNode(E);
if (!neo)
return false;
if (isEmpty())
head = neo;
else {
SLNode* tmp = head;
for (int i = 0; i < size - 1; i++)
tmp = tmp->getNext();
tmp->setNext(neo);
}
size++;
return true;
}