本文整理汇总了C++中SLNode::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ SLNode::getData方法的具体用法?C++ SLNode::getData怎么用?C++ SLNode::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SLNode
的用法示例。
在下文中一共展示了SLNode::getData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: print
void SLinkedList::print()const{
if(!(isEmpty())){
SLNode* tmpn = head;
for(int i = 0; i < ssize; i++){
tmpn->getData()->print();
tmpn = tmpn->getNext();
}
}
}
示例3: 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();
}
示例4: 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();
}
示例5: 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;
}
示例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;
}