Linpei's Blog
Saturday, 1 December 2012
Week 9 _unsigned int size()
unsigned int Queue::size() {
unsigned int size=0;
Node* n = _head;
if(!isEmpty()){
size =1;
while(n!=_tail) {
size++;
n = n->_next;
}
}
return size;
}
Week 9_int& operator[](unsigned int index)
int& Queue::operator[] (unsigned int index){
unsigned int size = this->size();
Node* idx = _head;
for(int i=0; i<int(index%size); i++){
idx = idx->_next;
}
return idx->_data;
}
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)