www.pudn.com > GraphCut.zip > LinkedBlockList.h


// LinkedBlockList.h: interface for the LinkedBlockList class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_LINKEDBLOCKLIST_H__5ADF95D9_E96B_4A76_A338_F50E4D791736__INCLUDED_) 
#define AFX_LINKEDBLOCKLIST_H__5ADF95D9_E96B_4A76_A338_F50E4D791736__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#define GCLL_BLOCK_SIZE 4   
// GCLL_BLOCKSIZE should "fit" into the type BlockType. That is  
// if GCLL_BLOCKSIZE is larger than 255 but smaller than largest short integer 
// then  BlockType should be set to short 
typedef char BlockType; 
 
//The type of data stored in the linked list 
typedef void * ListType; 
 
 
class LinkedBlockList   
{ 
 
public:  
	LinkedBlockList(); 
	virtual ~LinkedBlockList(); 
 
	void addFront(ListType item); 
	inline bool isEmpty(){if (m_head == 0) return(true); else return(false);}; 
	//inline LinkedBlockList(){m_head = 0; m_head_block_size = GCLL_BLOCK_SIZE;};  
	//~LinkedBlockList(); 
 
	// Next three functins are for the linked list traversal 
	inline void setCursorFront(){m_cursor = m_head; m_cursor_ind = 0;}; 
	ListType next(); 
	bool hasNext(); 
 
 
private: 
	typedef struct LLBlockStruct{ 
		ListType m_item[GCLL_BLOCK_SIZE]; 
		struct LLBlockStruct *m_next; 
	} LLBlock; 
 
	LLBlock *m_head; 
	// Remembers the number of elements in the head block, since it may not be full 
	BlockType m_head_block_size; 
	// For block traversal, points to current element in the current block 
	BlockType m_cursor_ind; 
	// For block traversal, points to current block in the linked list 
	LLBlock *m_cursor; 
 
}; 
 
#endif // !defined(AFX_LINKEDBLOCKLIST_H__5ADF95D9_E96B_4A76_A338_F50E4D791736__INCLUDED_)