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

📄 mmulist.h

📁 用c++变得一个测量财富的+游戏
💻 H
📖 第 1 页 / 共 2 页
字号:
/*\t*******************************************************************/
/*    Creation Date .......  Thu  05-20-1993  11:46:17                */
/*    Filename  ...........  mmulist.cpp                              */
/*    Project .............  Utilities                                */
/*    Author  .............  Matthew J. W. Ratcliff                   */
/*    Language  ...........  C++                                      */
/*    Operating System  ...  DOS/Windows                              */
/*    Processor  ..........  MMU - Memory Management Utilities        */
/*    Function:         C++ Linked List class.                        */
/*                                                                    */
/* Matthew Ratcliff's linked list class definitions. There are NO     */
/* INHERENT LIMITATIONS to this doubly linked list class.  Can't say  */
/* that about most other link list functions provided by Microsoft &  */
/* Borland libraries.                                                 */
/*                                                                    */
/* As of July 1994 I have over 150,000 lines of Windows & DOS         */
/* application C++ software that depend on this linked list class and */
/* its subclasses.  It works flawlessly.  It has been used in a Windoz*/
/* file viewer utility to view the entire contents of an ASCII file   */
/* containing 560 character lines, a total of 14 megabytes in size!   */
/* Try that with your Borland or Microsoft tools!                     */
/*                                                                    */
/*\t*******************************************************************/

/*\r********************************************************************
**                         Revision History
***********************************************************************/
/*

   Date    By           Change Description
dd-mmm-yy  nnn          text
---------  ----         -----------------------------------------------
20-May-93  MJWR         Linked list class.

**\r*/


#ifndef _MMULIST_H_
#define _MMULIST_H_

/*\i********************************************************************
**                       Module Include Files
***********************************************************************/

/*********************** System Include Files *************************/


/********************** Constant Include Files ************************/
#include "liidSys.h"


/***************** External Variable Include Files ********************/



/***************** External Procedure Include Files *******************/


/*\i*/

/*\m********************************************************************
**                       Module Declarations
***********************************************************************/

/************************* Module Constants ***************************/

/************************* Module Variables ***************************/

/************************* Module Procedures **************************/

/*\m*/

#include "mmplist.h" // public definitions for linked list package
#include "mmglist.h"


/*\p********************************************************************
**                                                                    **
**                                                                    **
    NAME:  MMUllist_class

    PURPOSE:  to declare a linked list class that makes it easy
      to generate and maintain a linked list.

**                                                                    **
**                                                                    **
**                                                                    **
**\p*******************************************************************/

class  MMUllist

{ /* MMUllist class */

/********************** friend declarations ***************************/

/********************** public declarations ***************************/
public:

                        MMUllist();
                        ~MMUllist();

// Copy contents of this linked list to the
// referenced destination. Start at FIRST of
// this list and APPEND all to refList.
STAT_TYPE               CopyTo( MMUllist *refList );
MMP_DATA_TY            *First();
MMP_DATA_TY            *Last();
MMP_DATA_TY            *Next();
MMP_DATA_TY            *Prev();
MMP_DATA_TY            *Current();
INT32                   NumEntries();
MMP_DATA_TY            *Indexed( INT32 pasIndex );
INT32                   GetIndexOfCurrent();

/****************************************
* This list makes copies of the data
* passed in.  Thus, your data entries
* can be stored in a single local
* variable, update it, and stick each
* version of the variable into the list.
* That is, you needn't allocate storage
* for the bodies of the entries added
* to this list.
*/

STAT_TYPE               InsertBeforeHead   ( MMP_DATA_TY &pasEntry );

STAT_TYPE               AppendAfterTail    ( MMP_DATA_TY &pasEntry );

STAT_TYPE               InsertBeforeCurrent( MMP_DATA_TY &pasEntry );

STAT_TYPE               InsertAfterCurrent( MMP_DATA_TY &pasEntry );

STAT_TYPE               InsertBeforeHead   ( INT32       pasSizeOfBuf,
                                             void       *pasBufPtr );

STAT_TYPE               AppendAfterTail    ( INT32       pasSizeOfBuf,
                                             void       *pasBufPtr );

STAT_TYPE               InsertBeforeCurrent( INT32       pasSizeOfBuf,
                                             void       *pasBufPtr );

STAT_TYPE               InsertAfterCurrent( INT32       pasSizeOfBuf,
                                            void       *pasBufPtr );
/****************************************
* Delete current entry from the list
*/

STAT_TYPE               DeleteCurrentEntry();

/****************************************
* Delete the entire list.  Empties the
* list, but does not delete the linked
* list itself - you can immediately
* start adding new entries afterwards
* if desired.
*/

STAT_TYPE               DeleteList();


/****************************************
* This method is used to build a list,
* sorted by ascii identifier strings.
* For example, to let the user
* build a list of sorted strings:
*
* #include <string.h>
*
* MMP_LLIST_TY *mmlList;
* MMP_DATA_TY  *mmlDatum;
* do
*  {
*   gets(instr);
*   if (*instr)
*     {
*     mmlList.InsertSorted( strcmp, strlen(instr), instr );
*     }
*   }
* while (*instr);
*
* // Print the sorted list now
*
* mmlDatum = mmlList.First();
* while (mmlDatum)
*   {
*   printf("%s\n", (char *)mmlDatum->body;
*   }
* mmlList.DeleteList();
*
*
*
* Now, suppose you have a STRUCTURE, such as file names,
* size, date, etc.
*
* typedef struct { char fileName[13];
*                  INT32 fileSize;
*                  char date[20];
*                } FIP_FILE_TY;
*
* Then build a sorted list like this:
*
* When using structures instead of strings,
* the only REQUIREMENT is that the first
* record of the buffer is the string
* used for comparison.  If this rule
* is not followed, unpredictable
* results will occur.
*
* int fileCompare( const void *f1, const void *f2 )
* {
* FIP_FILE_TY *ff1, *ff2;
* int cmp;
*
* ff1 = (FIP_FILE_TY *)f1;
* ff2 = (FIP_FILE_TY *)f2;
* cmp = strcmpi(ff1->fileName, ff2->fileName);
* if (cmp == 0)
*   {
*   cmp = strcmpi(ff1->fileDate, ff2->fileDate);
*   if (cmp == 0)
*     {
*     lcmp = ff2->fileSize - ff1->fileSize;
*     if (lcmp < 0)      cmp = -1;
*     else if (lcmp > 0) cmp = 1;
*     else               cmp = 0;
*     }
*   }
* return(cmp);
* }
*
* buildFlist()
* {
* FIP_FILE_TY filInfo;
* int         filStatus;
* MMUllist    filFlist;
* MMP_DATA_TY *filEntry;
* FIP_FILE_TY *filPtr;
*
* do
*   {
*   filStatus = fiuGetFileInfo( &filInfo );

⌨️ 快捷键说明

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