⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clst.h

📁 一OCR的相关资料。.希望对研究OCR的朋友有所帮助.
💻 H
📖 第 1 页 / 共 3 页
字号:
                                 //we're at a deleted  return ((list->empty ()) || (current == list->last) || ((current == NULL) &&    (prev == list->last) &&      //last point between    ex_current_was_last));       //first and last}/*********************************************************************** *							CLIST_ITERATOR::cycled_list() * *  Have we returned to the cycle_pt since it was set? * **********************************************************************/inline BOOL8 CLIST_ITERATOR::cycled_list() {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("CLIST_ITERATOR::cycled_list", ABORT, NULL);  if (!list)    NO_LIST.error ("CLIST_ITERATOR::cycled_list", ABORT, NULL);  #endif  return ((list->empty ()) || ((current == cycle_pt) && started_cycling));}/*********************************************************************** *							CLIST_ITERATOR::length() * *  Return the length of the list * **********************************************************************/inline INT32 CLIST_ITERATOR::length() {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("CLIST_ITERATOR::length", ABORT, NULL);  if (!list)    NO_LIST.error ("CLIST_ITERATOR::length", ABORT, NULL);  #endif  return list->length ();}/*********************************************************************** *							CLIST_ITERATOR::sort() * *  Sort the elements of the list, then reposition at the start. * **********************************************************************/inline voidCLIST_ITERATOR::sort (           //sort elementsint comparator (                 //comparison routineconst void *, const void *)) {  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("CLIST_ITERATOR::sort", ABORT, NULL);  if (!list)    NO_LIST.error ("CLIST_ITERATOR::sort", ABORT, NULL);  #endif  list->sort (comparator);  move_to_first();}/*********************************************************************** *							CLIST_ITERATOR::add_to_end * *  Add a new element to the end of the list without moving the iterator. *  This is provided because a single linked list cannot move to the last as *  the iterator couldn't set its prev pointer.  Adding to the end is *  essential for implementing              queues.**********************************************************************/inline void CLIST_ITERATOR::add_to_end(  // element to add                                       void *new_data) {  CLIST_LINK *new_element;  #ifdef _DEBUG  if (!this)    NULL_OBJECT.error ("CLIST_ITERATOR::add_to_end", ABORT, NULL);  if (!list)    NO_LIST.error ("CLIST_ITERATOR::add_to_end", ABORT, NULL);  if (!new_data)    BAD_PARAMETER.error ("CLIST_ITERATOR::add_to_end", ABORT,      "new_data is NULL");  #endif  if (this->at_last ()) {    this->add_after_stay_put (new_data);  }  else {    if (this->at_first ()) {      this->add_before_stay_put (new_data);      list->last = prev;    }    else {                       //Iteratr is elsewhere      new_element = new CLIST_LINK;      new_element->data = new_data;      new_element->next = list->last->next;      list->last->next = new_element;      list->last = new_element;    }  }}/***********************************************************************  QUOTE_IT   MACRO DEFINITION  ===========================Replace <parm> with "<parm>".  <parm> may be an arbitrary number of tokens***********************************************************************/#define QUOTE_IT( parm ) #parm/***********************************************************************  CLISTIZE( CLASSNAME ) MACRO DEFINITION  ======================================CLASSNAME is assumed to be the name of a class to be used in a CONS listNOTE:  Because we dont use virtual functions in the list code, the list codewill NOT work correctly for classes derived from this.The macro generates:  - An element deletion function:      CLASSNAME##_c1_zapper  - An element copier function:              CLASSNAME##_c1_copier  - An element serialiser function"    CLASSNAME##_c1_serialiser  - An element de-serialiser function" CLASSNAME##_c1_de_serialiser  - A CLIST subclass:		CLASSNAME##_CLIST  - A CLIST_ITERATOR subclass:              CLASSNAME##_C_ITNOTE: Generated names do NOT clash with those generated by ELISTIZE,ELIST2ISE and CLIST2IZEFour macros are provided: CLISTIZE, CLISTIZE_S, CLISTIZEH and CLISTIZEH_SThe ...IZEH macros just define the class names for use in .h filesThe ...IZE macros define the code use in .c filesThe _S versions define lists which can be serialised.  They assume that themake_serialise() macro is used in the list element class to defineserialise() and de_serialise() members for the list elements.This, in turn, assumes that the list element class has prep_serialise()dump() and de_dump() member functions.***********************************************************************//***********************************************************************  CLISTIZEH( CLASSNAME )  and  CLISTIZEH_S( CLASSNAME ) MACROSThese macros are constructed from 3 fragments CLISTIZEH_A, CLISTIZEH_B andCLISTIZEH_C.  CLISTIZEH is simply a concatenation of these parts.CLISTIZEH_S has some additional bits thrown in the gaps.***********************************************************************/#define CLISTIZEH_A( CLASSNAME )												\																				\extern DLLSYM void			CLASSNAME##_c1_zapper(		/*delete a link*/		\void*						link);						/*link to delete*/		\																				\extern DLLSYM void*			CLASSNAME##_c1_copier(		/*deep copy a link*/	\void*						old_element);   /*source link */#define CLISTIZEH_B( CLASSNAME )												\																				\/***********************************************************************		\*							CLASS - CLASSNAME##_CLIST							\*																				\*							List class for class CLASSNAME						\*																				\**********************************************************************/			\																				\class DLLSYM				CLASSNAME##_CLIST : public CLIST					\{																				\public:																			\							CLASSNAME##_CLIST():CLIST() {}						\														/* constructor */		\																				\							CLASSNAME##_CLIST(	/* dont construct */			\	const CLASSNAME##_CLIST&)							/*by initial assign*/	\	{ DONT_CONSTRUCT_LIST_BY_COPY.error( QUOTE_IT( CLASSNAME##_CLIST ),			\														ABORT, NULL ); }		\																				\void						deep_clear()				/* delete elements */	\	{ CLIST::internal_deep_clear( &CLASSNAME##_c1_zapper ); }					\																				\void						deep_copy(					/* become a deep */		\	const CLASSNAME##_CLIST*list)						/* copy of src list*/	\	{ CLIST::internal_deep_copy( &CLASSNAME##_c1_copier, list ); }				\																				\void						operator=(					/* prevent assign */	\	const CLASSNAME##_CLIST&)													\	{ DONT_ASSIGN_LISTS.error( QUOTE_IT( CLASSNAME##_CLIST ),					\											ABORT, NULL ); }#define CLISTIZEH_C( CLASSNAME )												\																				\};																				\																				\																				\																				\/***********************************************************************		\*							CLASS - CLASSNAME##_C_IT							\*																				\*							Iterator class for class CLASSNAME##_CLIST			\*																				\*  Note: We don't need to coerce pointers to member functions input				\*  parameters as these are automatically converted to the type of the base		\*  type. ("A ptr to a class may be converted to a pointer to a public base		\*  class of that class")														\**********************************************************************/			\																				\class DLLSYM				CLASSNAME##_C_IT : public CLIST_ITERATOR			\{																				\public:																			\							CLASSNAME##_C_IT():CLIST_ITERATOR(){}				\																				\							CLASSNAME##_C_IT(									\	CLASSNAME##_CLIST*		list):CLIST_ITERATOR(list){}						\																				\	CLASSNAME*			data()												\		{ return (CLASSNAME*) CLIST_ITERATOR::data(); }						\																				\	CLASSNAME*			data_relative(										\	INT8					offset)												\		{ return (CLASSNAME*) CLIST_ITERATOR::data_relative( offset ); }		\																				\	CLASSNAME*			forward()											\		{ return (CLASSNAME*) CLIST_ITERATOR::forward(); }					\																				\	CLASSNAME*			extract()											\		{ return (CLASSNAME*) CLIST_ITERATOR::extract(); }					\																				\	CLASSNAME*			move_to_first()										\		{ return (CLASSNAME*) CLIST_ITERATOR::move_to_first(); }				\																				\	CLASSNAME*			move_to_last()										\		{ return (CLASSNAME*) CLIST_ITERATOR::move_to_last(); }				\};#define CLISTIZEH( CLASSNAME )													\																				\CLISTIZEH_A( CLASSNAME )														\																				\CLISTIZEH_B( CLASSNAME )														\																				\CLISTIZEH_C( CLASSNAME )#define CLISTIZEH_S( CLASSNAME )												\																				\CLISTIZEH_A( CLASSNAME )														\																				\extern DLLSYM void			CLASSNAME##_c1_serialiser(							\FILE*						f,													\void*						element);											\																				\extern DLLSYM void*			CLASSNAME##_c1_de_serialiser(						\FILE*						f);													\																				\CLISTIZEH_B( CLASSNAME )														\																				\	void					dump(						/* dump to file */		\	FILE*					f)													\	{ CLIST::internal_dump( f, &CLASSNAME##_c1_serialiser );}					\																				\	void					de_dump(					/* get from file */		\	FILE*					f)													\	{ CLIST::internal_de_dump( f, &CLASSNAME##_c1_de_serialiser );}				\																				\make_serialise( CLASSNAME##_CLIST )												\																				\CLISTIZEH_C( CLASSNAME )/***********************************************************************  CLISTIZE( CLASSNAME )  and   CLISTIZE_S( CLASSNAME )  MACROSCLISTIZE_S is a simple extension to CLISTIZE***********************************************************************/#define CLISTIZE( CLASSNAME )													\																				\/***********************************************************************		\*							CLASSNAME##_c1_zapper								\*																				\*  A function which can delete a CLASSNAME element.  This is passed to the		\*  generic deep_clear list member function so that when a list is cleared the	\*  elements on the list are properly destroyed from the base class, even		\*  though we dont use a virtual destructor function.							\**********************************************************************/			\																				\DLLSYM void					CLASSNAME##_c1_zapper(		/*delete a link*/		\void*						link)						/*link to delete*/		\{																				\delete (CLASSNAME *) link;														\}																				\																				\																				\																				\/***********************************************************************		\*							CLASSNAME##_c1_copier								\*																				\*  A function which can generate a new, deep copy of a CLASSNAME element.		\*  This is passed to the generic deep copy list member function so that when	\*  a list is copied the elements on the list are properly copied from the		\*  base class, even though we dont use a virtual function.						\*																				\**********************************************************************/			\																				\DLLSYM void*				CLASSNAME##_c1_copier(		/*deep copy a link*/	\void*						old_element)				/*source link*/			\{																				\	CLASSNAME*			new_element;										\																				\new_element = new CLASSNAME;													\*new_element = *((CLASSNAME*) old_element);									\return (void*) new_element;														\}#define CLISTIZE_S( CLASSNAME )													\																				\CLISTIZE( CLASSNAME )															\																				\/***********************************************************************		\*							CLASSNAME##_c1_serialiser							\*																				\*  A function which can serialise an element									\*  This is passed to the generic dump member function so that when a list is	\*  serialised the elements on the list are properly serialised.					\**********************************************************************/			\																				\DLLSYM void					CLASSNAME##_c1_serialiser(							\FILE*						f,													\void*						element)											\{																				\((CLASSNAME*) element)->serialise( f );										\}																				\																				\																				\																				\/***********************************************************************		\*							CLASSNAME##_c1_de_serialiser						\*																				\*  A function which can de-serialise an element									\*  This is passed to the generic de-dump member function so that when a list	\*  is de-serialised the elements on the list are properly de-serialised.		\**********************************************************************/			\																				\DLLSYM void*				CLASSNAME##_c1_de_serialiser(						\FILE*						f)													\{																				\return CLASSNAME::de_serialise( f );											\}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -