📄 mmulist.cpp
字号:
/*\p********************************************************************
** **
** **
NAME: MMUllist::DeleteList
PURPOSE: to delete all entries entry in the list.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::DeleteList()
{ /* MMUllist::DeleteList procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
MMG_LLIST_TY *mmlEntry;
MMG_LLIST_TY *mmlNext;
/************************* Procedure Body *****************************/
/* Initialize return val */
mmlErr = SUCCEEDED_;
if (current != NULL && numEntries != 0)
{
mmlEntry = head;
mmlNext = head->next;
while (mmlEntry != NULL)
{
mmlErr = mmuDestroyEntry( mmlEntry );
mmlEntry = mmlNext;
if (mmlNext != NULL)
{
mmlNext = mmlNext->next;
}
}
numEntries = 0;
head = NULL;
tail = NULL;
current = NULL;
}
return(mmlErr);
} /* MMUllist::DeleteList end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::First
PURPOSE: to return the address of the first data item
in the list. On error return NULL.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlDat FNC MMP_DATA_TY *, address of data buffer **
**\p*******************************************************************/
MMP_DATA_TY *MMUllist::First( )
{ /* MMUllist::First procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
MMP_DATA_TY *mmlDat = NULL;
/************************* Procedure Body *****************************/
if (numEntries != 0L)
{
mmlDat = &head->buf;
current = head;
}
return(mmlDat);
} /* MMUllist::First end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::Last
PURPOSE: to return the address of the last data item
in the list. On error return NULL.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlDat FNC MMP_DATA_TY *, address of data buffer **
**\p*******************************************************************/
MMP_DATA_TY *MMUllist::Last( )
{ /* MMUllist::Last procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
MMP_DATA_TY *mmlDat = NULL;
/************************* Procedure Body *****************************/
if (numEntries != 0L)
{
mmlDat = &tail->buf;
current = tail;
}
return(mmlDat);
} /* MMUllist::Last end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::Next
PURPOSE: to return the address of the next data item
in the list. On error return NULL.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlDat FNC MMP_DATA_TY *, address of data buffer **
**\p*******************************************************************/
MMP_DATA_TY *MMUllist::Next( )
{ /* MMUllist::Next procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
MMP_DATA_TY *mmlDat = NULL;
/************************* Procedure Body *****************************/
if (numEntries != 0L)
{
if (current != tail)
{
current = current->next;
mmlDat = ¤t->buf;
}
}
return(mmlDat);
} /* MMUllist::Next end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::Prev
PURPOSE: to return the address of the previous data item
in the list. On error return NULL.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlDat FNC MMP_DATA_TY *, address of data buffer **
**\p*******************************************************************/
MMP_DATA_TY *MMUllist::Prev( )
{ /* MMUllist::Prev procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
MMP_DATA_TY *mmlDat = NULL;
/************************* Procedure Body *****************************/
if (numEntries != 0L)
{
if (current != head)
{
current = current->prev;
mmlDat = ¤t->buf;
}
}
return(mmlDat);
} /* MMUllist::Prev end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::Current
PURPOSE: to return the address of the current data item
in the list. On error return NULL.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlDat FNC MMP_DATA_TY *, address of data buffer **
**\p*******************************************************************/
MMP_DATA_TY *MMUllist::Current( )
{ /* MMUllist::Current procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
MMP_DATA_TY *mmlDat = NULL;
/************************* Procedure Body *****************************/
if (numEntries != 0L)
{
if (current != NULL)
{
mmlDat = ¤t->buf;
}
}
return(mmlDat);
} /* MMUllist::Current end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::NumEntries
PURPOSE: to return the count of the number of entries
currently in the list.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** numEntries FNC # of entries in list, currently **
**\p*******************************************************************/
INT32 MMUllist::NumEntries( )
{ /* MMUllist::NumEntries procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/************************* Procedure Body *****************************/
return(numEntries );
} /* MMUllist::NumEntries end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::Indexed
PURPOSE: to return the address of the indexed data item
in the list. On error return NULL.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlDat FNC MMP_DATA_TY *, address of data buffer **
**\p*******************************************************************/
MMP_DATA_TY *MMUllist::Indexed( INT32 pasIndex )
{ /* MMUllist::Indexed procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
MMP_DATA_TY *mmlDat = NULL;
INT32 mmlCt;
/************************* Procedure Body *****************************/
if (numEntries > pasIndex)
{
current = head;
mmlCt = pasIndex;
while (mmlCt != 0 && current != NULL)
{
current = current->next;
mmlCt--;
}
if (current != NULL)
{
mmlDat = ¤t->buf;
}
}
return(mmlDat);
} /* MMUllist::Indexed end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::InsertSorted
PURPOSE: to insert a record sorted, based on the user's
"compare" function pointer
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::InsertSorted
( int (* pasFncCompare) (const void *pasStru1,
const void *pasStru2 ),
INT32 pasSizeOfBuf,
void *pasBufPtr )
{ /* MMUllist::InsertSorted procedure */
/******************* Local Constant Declarations **********************/
/* Proc name for error log */
#define MML_INSERT_AT_HEAD 0
#define MML_INSERT_AT_CURRENT 1
#define MML_INSERT_AT_TAIL 2
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -