Subversion Repositories spk

Rev

Rev 9 | Rev 121 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9 Rev 10
Line 119... Line 119...
119
	{ 
119
	{ 
120
		if ( !m_pItr ) 
120
		if ( !m_pItr ) 
121
			return NULL; 
121
			return NULL; 
122
		return m_pItr->Data(); 
122
		return m_pItr->Data(); 
123
	}
123
	}
124
	CListNode<LINKCLASS> *CurrentNode () { if ( m_bCurrentStart ) return m_pFront; return m_pCurrent; }
124
	CListNode<LINKCLASS> *CurrentNode () const { if ( m_bCurrentStart ) return m_pFront; return m_pCurrent; }
125
	LINKCLASS *CurrentData () { if ( (m_bCurrentStart) && (m_pFront) ) return m_pFront->Data(); if ( (m_pCurrent) && (!m_bCurrentStart) ) return m_pCurrent->Data(); return NULL; }
125
	LINKCLASS *CurrentData () const { if ( (m_bCurrentStart) && (m_pFront) ) return m_pFront->Data(); if ( (m_pCurrent) && (!m_bCurrentStart) ) return m_pCurrent->Data(); return NULL; }
126
	CListNode<LINKCLASS> *SetCurrentFront () { m_pCurrent = m_pFront; m_bCurrentStart = false; return m_pCurrent; }
126
	CListNode<LINKCLASS> *SetCurrentFront () { m_pCurrent = m_pFront; m_bCurrentStart = false; return m_pCurrent; }
127
	CListNode<LINKCLASS> *SetCurrentBack () { m_pCurrent = m_pBack; m_bCurrentStart = false; return m_pCurrent; }
127
	CListNode<LINKCLASS> *SetCurrentBack () { m_pCurrent = m_pBack; m_bCurrentStart = false; return m_pCurrent; }
128
	CListNode<LINKCLASS> *MoveCurrentNext () { if ( m_bCurrentStart ) { m_pCurrent = m_pFront; m_bCurrentStart = false; } else if ( m_pCurrent ) m_pCurrent = m_pCurrent->next(); return m_pCurrent; }
128
	CListNode<LINKCLASS> *MoveCurrentNext () { if ( m_bCurrentStart ) { m_pCurrent = m_pFront; m_bCurrentStart = false; } else if ( m_pCurrent ) m_pCurrent = m_pCurrent->next(); return m_pCurrent; }
129
	CListNode<LINKCLASS> *MoveCurrentPrev () { if ( m_pCurrent ) m_pCurrent = m_pCurrent->prev(); return m_pCurrent; }
129
	CListNode<LINKCLASS> *MoveCurrentPrev () { if ( m_pCurrent ) m_pCurrent = m_pCurrent->prev(); return m_pCurrent; }
130
	void RemoveCurrent () 
130
	void RemoveCurrent () 
Line 158... Line 158...
158
 
158
 
159
	int size () const { return elements; } // return the num of elements in list
159
	int size () const { return elements; } // return the num of elements in list
160
	void incElement () { elements++; } // Increment elements, used when new node is added
160
	void incElement () { elements++; } // Increment elements, used when new node is added
161
	void decElement () { elements--; } // Decrement elements, used when new node is deleted
161
	void decElement () { elements--; } // Decrement elements, used when new node is deleted
162
 
162
 
163
	CListNode<LINKCLASS> *Front () { return ( m_pFront ); } // return the first node in the list
163
	CListNode<LINKCLASS> *Front () const { return ( m_pFront ); } // return the first node in the list
164
	CListNode<LINKCLASS> *Back () { return ( m_pBack ); } // return the last node in the list
164
	CListNode<LINKCLASS> *Back () const { return ( m_pBack ); } // return the last node in the list
165
	LINKCLASS *First () { SetCurrentFront(); if ( m_pCurrent ) return ( m_pCurrent->Data() ); return ( NULL ); } // return the first node in the list
165
	LINKCLASS *First () { SetCurrentFront(); if ( m_pCurrent ) return ( m_pCurrent->Data() ); return ( NULL ); } // return the first node in the list
166
	LINKCLASS *Last () { SetCurrentBack(); if ( m_pCurrent ) return ( m_pCurrent->Data() ); return (NULL ); } // return the last node in the list
166
	LINKCLASS *Last () { SetCurrentBack(); if ( m_pCurrent ) return ( m_pCurrent->Data() ); return (NULL ); } // return the last node in the list
167
	LINKCLASS *Next () { if ( MoveCurrentNext() ) return m_pCurrent->Data(); return NULL; }
167
	LINKCLASS *Next () { if ( MoveCurrentNext() ) return m_pCurrent->Data(); return NULL; }
168
	LINKCLASS *Prev () { if ( MoveCurrentPrev() ) return m_pCurrent->Data(); return NULL; }
168
	LINKCLASS *Prev () { if ( MoveCurrentPrev() ) return m_pCurrent->Data(); return NULL; }
169
 
169
 
Line 208... Line 208...
208
 
208
 
209
			curNode = nextNode;
209
			curNode = nextNode;
210
		}
210
		}
211
	}
211
	}
212
 
212
 
213
	bool empty() { // return true is the list is empty, otherwise return false
213
	bool empty() const { // return true is the list is empty, otherwise return false
214
		if ( (elements <= 0) || (!m_pFront) ) 
214
		if ( (elements <= 0) || (!m_pFront) ) 
215
			return true;
215
			return true;
216
		else
216
		else
217
			return false;
217
			return false;
218
	}
218
	}
Line 521... Line 521...
521
		return (*this);
521
		return (*this);
522
	}
522
	}
523
 
523
 
524
	LINKCLASS *operator[](int pos) { return Get(pos); }
524
	LINKCLASS *operator[](int pos) { return Get(pos); }
525
 
525
 
526
	LINKCLASS *Get ( int id )
526
	LINKCLASS *Get ( int id ) const
527
	{
527
	{
528
		int i = 0;
528
		int i = 0;
529
		if ( !m_pFront )
529
		if ( !m_pFront )
530
			return NULL;
530
			return NULL;
531
 
531
 
Line 538... Line 538...
538
			++i;
538
			++i;
539
		}
539
		}
540
		return NULL;
540
		return NULL;
541
	}
541
	}
542
 
542
 
543
	CListNode<LINKCLASS> *GetNode ( int id )
543
	CListNode<LINKCLASS> *GetNode ( int id ) const
544
	{
544
	{
545
		int i = 0;
545
		int i = 0;
546
		if ( !m_pFront )
546
		if ( !m_pFront )
547
			return NULL;
547
			return NULL;
548
 
548
 
Line 566... Line 566...
566
				node->ChangeData ( n );
566
				node->ChangeData ( n );
567
			node = node->next();
567
			node = node->next();
568
		}
568
		}
569
	}
569
	}
570
 
570
 
571
	bool FindData ( LINKCLASS *e )
571
	bool FindData ( LINKCLASS *e ) const
572
	{
572
	{
573
		CListNode<LINKCLASS> *node = m_pFront;
573
		CListNode<LINKCLASS> *node = m_pFront;
574
		while ( node )
574
		while ( node )
575
		{
575
		{
576
			if ( node->Data() == e )
576
			if ( node->Data() == e )
Line 578... Line 578...
578
			node = node->next();
578
			node = node->next();
579
		}
579
		}
580
		return false;
580
		return false;
581
	}
581
	}
582
 
582
 
583
	int FindPos ( LINKCLASS *e )
583
	int FindPos ( LINKCLASS *e ) const
584
	{
584
	{
585
		int pos = 0;
585
		int pos = 0;
586
		CListNode<LINKCLASS> *node = m_pFront;
586
		CListNode<LINKCLASS> *node = m_pFront;
587
		while ( node )
587
		while ( node )
588
		{
588
		{