示例#1
0
void PointerFIFO::put(void* val)
{
	ListNode *node = allocate();
	node->data(val);
	node->next(NULL);
	if (mTail!=NULL) mTail->next(node);
	mTail=node;
	if (mHead==NULL) mHead=node;
	mSize++;
}
示例#2
0
void PointerFIFO::push_front(void* val)	// by pat
{
	// Pat added this routine for completeness, but never used or tested.
	// The first person to use this routine should remove this assert.
	ListNode *node = allocate();
	node->data(val);
	node->next(mHead);
	mHead = node;
	if (!mTail) mTail=node;
	mSize++;
}
示例#3
0
文件: List.cpp 项目: yilirin/CPPHW2
//尾部扩充
void CPPList::append(int number){
    ListNode * newNode = new ListNode();
    newNode->data() = number;
    if (is_empty()) {
        ListHeader = newNode;
        ListEnd = newNode;
    }
    else {
        ListEnd->next = newNode;
        ListEnd = ListEnd->next;
    }
    newNode->next = ListTrailer;
    _size++;
}
示例#4
0
文件: List.cpp 项目: yilirin/CPPHW2
void CPPList::insert(ListNode *current, int number){
    if (!is_empty()){                               //do not insert if the list is empty
        ListNode *tmp = new ListNode;
        tmp->data() = number;
        if (current == ListHeader) {
            tmp->next = current;
            ListHeader = tmp;
        }
        else {
            tmp->next = current;
            findPreNode(current)->next = tmp;
        }
         _size++;
    }
   
}