📄 mmulist.cpp
字号:
/************************* Procedure Body *****************************/
mmlErr = InsertBeforeCurrent( pasEntry.size, pasEntry.body );
return(mmlErr);
} /* MMUllist::InsertBeforeCurrent end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::InsertAfterCurrent
PURPOSE: to insert a new entry after the current entry
in the list
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::InsertAfterCurrent( MMP_DATA_TY &pasEntry )
{ /* MMUllist::InsertAfterCurrent procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
/************************* Procedure Body *****************************/
mmlErr = InsertAfterCurrent( pasEntry.size, pasEntry.body );
return(mmlErr);
} /* MMUllist::InsertAfterCurrent end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::InsertBeforeHead
PURPOSE: to insert a new entry before the head of the list.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::InsertBeforeHead( INT32 pasSizeofBuf,
void *pasBufPtr )
{ /* MMUllist::InsertBeforeHead procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
MMG_LLIST_TY *mmlEntry;
MMG_LLIST_TY *mmlPtr;
/************************* Procedure Body *****************************/
/* Initialize return val */
mmlErr = FAILED_;
if (pasSizeofBuf > 0)
{
mmlEntry = mmuCreateEntry( pasSizeofBuf, pasBufPtr );
if (mmlEntry != NULL && head != NULL)
{
mmlErr = SUCCEEDED_;
mmlPtr = head;
mmlPtr->prev = mmlEntry;
mmlEntry->prev = NULL;
mmlEntry->next = head;
current = mmlEntry;
head = mmlEntry;
numEntries++;
}
else if (mmlEntry != NULL) // first entry
{
mmlErr = mmuSetFirstEntry( mmlEntry );
}
}
return(mmlErr);
} /* MMUllist::InsertBeforeHead end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::AppendAfterTail
PURPOSE: to insert a new entry after the end of the list.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::AppendAfterTail( INT32 pasSizeofBuf,
void *pasBufPtr )
{ /* MMUllist::AppendAfterTail procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
MMG_LLIST_TY *mmlEntry;
/************************* Procedure Body *****************************/
/* Initialize return val */
mmlErr = FAILED_;
if (pasSizeofBuf > 0)
{
mmlEntry = mmuCreateEntry( pasSizeofBuf, pasBufPtr );
if (mmlEntry != NULL && tail != NULL)
{
mmlErr = SUCCEEDED_;
tail->next = mmlEntry;
mmlEntry->prev = tail;
mmlEntry->next = NULL;
tail = mmlEntry;
current = mmlEntry;
numEntries++;
}
else if (mmlEntry != NULL) // first entry
{
mmlErr = mmuSetFirstEntry( mmlEntry );
}
}
return(mmlErr);
} /* MMUllist::AppendAfterTail end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::InsertBeforeCurrent
PURPOSE: to insert a new entry before the current entry in
the list.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::InsertBeforeCurrent( INT32 pasSizeofBuf,
void *pasBufPtr )
{ /* MMUllist::InsertBeforeCurrent procedure */
/******************* Local Constant Declarations **********************/
/* Proc name for error log */
//CHARPTR MML_PROC_NAME = "MMUllist::InsertBeforeCurrent";
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
MMG_LLIST_TY *mmlEntry;
MMG_LLIST_TY *mmlPrev;
/************************* Procedure Body *****************************/
/* Initialize return val */
mmlErr = FAILED_;
if (pasSizeofBuf > 0)
{
if (current == head)
{
mmlErr = InsertBeforeHead( pasSizeofBuf, pasBufPtr );
}
else
{
mmlErr = SUCCEEDED_;
mmlEntry = mmuCreateEntry( pasSizeofBuf, pasBufPtr );
if (mmlEntry != NULL && current != NULL)
{
mmlPrev = current->prev;
mmlEntry->prev = current->prev;
mmlEntry->next = current;
current->prev = mmlEntry;
if (mmlPrev != NULL)
{
mmlPrev->next = mmlEntry;
}
current = mmlEntry;
numEntries++;
}
else if (mmlEntry != NULL) // first entry
{
mmlErr = mmuSetFirstEntry( mmlEntry );
}
}
}
return(mmlErr);
} /* MMUllist::InsertBeforeCurrent end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::InsertAfterCurrent
PURPOSE: to insert a new entry after the current entry in
the list, such that Next() will return THIS entry,
without affecting what is NOW CURRENT.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::InsertAfterCurrent( INT32 pasSizeofBuf,
void *pasBufPtr )
{ /* MMUllist::InsertAfterCurrent procedure */
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
MMG_LLIST_TY *mmlEntry;
MMG_LLIST_TY *mmlNext;
/************************* Procedure Body *****************************/
/* Initialize return val */
mmlErr = FAILED_;
if (pasSizeofBuf > 0)
{
if (current == tail)
{
mmlErr = AppendAfterTail( pasSizeofBuf, pasBufPtr );
Prev();
}
else
{
mmlErr = SUCCEEDED_;
mmlEntry = mmuCreateEntry( pasSizeofBuf, pasBufPtr );
if (mmlEntry != NULL && current != NULL)
{
mmlNext = current->next;
current->next = mmlEntry;
mmlEntry->next = mmlNext;
mmlEntry->prev = current;
numEntries++;
}
else if (mmlEntry != NULL) // first entry
{
mmlErr = mmuSetFirstEntry( mmlEntry );
}
}
}
return(mmlErr);
} /* MMUllist::InsertAfterCurrent end */
/*\p********************************************************************
** **
** **
NAME: MMUllist::DeleteCurrentEntry
PURPOSE: to delete the current entry in the list.
Current becomes current->next.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** mmlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE MMUllist::DeleteCurrentEntry()
{ /* MMUllist::DeleteCurrentEntry procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/* error return flag */
STAT_TYPE mmlErr;
MMG_LLIST_TY *mmlEntry;
MMG_LLIST_TY *mmlCurrent0;
MMG_LLIST_TY *mmlCurrent1;
/************************* Procedure Body *****************************/
/* Initialize return val */
mmlErr = SUCCEEDED_;
if (current != NULL && numEntries != 0)
{
if (numEntries == 1)
{
mmlEntry = head;
mmlErr = mmuDestroyEntry( mmlEntry );
numEntries = 0;
head = NULL;
tail = NULL;
current = NULL;
}
else
{
if (current == head)
{ // delete head entry
mmlEntry = head;
head = head->next;
current = head;
mmlErr = mmuDestroyEntry( mmlEntry );
}
else if (current == tail)
{
mmlEntry = tail;
tail = tail->prev;
current = tail;
mmlErr = mmuDestroyEntry( mmlEntry );
}
else
{ // Extract entry and mend over the hole
mmlEntry = current;
mmlCurrent0 = current->prev;
mmlCurrent1 = current->next;
mmlCurrent0->next = mmlCurrent1;
mmlCurrent1->prev = mmlCurrent0;
mmlErr = mmuDestroyEntry( mmlEntry );
current = mmlCurrent1;
}
numEntries--;
}
}
return(mmlErr);
} /* MMUllist::DeleteCurrentEntry end */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -