Annotation of 43BSDReno/usr.bin/make/lst.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
        !             3:  * Copyright (c) 1988, 1989 by Adam de Boor
        !             4:  * Copyright (c) 1989 by Berkeley Softworks
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * This code is derived from software contributed to Berkeley by
        !             8:  * Adam de Boor.
        !             9:  *
        !            10:  * Redistribution and use in source and binary forms are permitted
        !            11:  * provided that: (1) source distributions retain this entire copyright
        !            12:  * notice and comment, and (2) distributions including binaries display
        !            13:  * the following acknowledgement:  ``This product includes software
        !            14:  * developed by the University of California, Berkeley and its contributors''
        !            15:  * in the documentation or other materials provided with the distribution
        !            16:  * and in all advertising materials mentioning features or use of this
        !            17:  * software. Neither the name of the University nor the names of its
        !            18:  * contributors may be used to endorse or promote products derived
        !            19:  * from this software without specific prior written permission.
        !            20:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            21:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            22:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            23:  *
        !            24:  *     @(#)lst.h       5.3 (Berkeley) 6/1/90
        !            25:  */
        !            26: 
        !            27: /*-
        !            28:  * lst.h --
        !            29:  *     Header for using the list library
        !            30:  */
        !            31: #ifndef _LST_H_
        !            32: #define _LST_H_
        !            33: 
        !            34: #include       <sprite.h>
        !            35: 
        !            36: /*
        !            37:  * basic typedef. This is what the Lst_ functions handle
        !            38:  */
        !            39: 
        !            40: typedef        struct  Lst     *Lst;
        !            41: typedef        struct  LstNode *LstNode;
        !            42: 
        !            43: #define        NILLST          ((Lst) NIL)
        !            44: #define        NILLNODE        ((LstNode) NIL)
        !            45: 
        !            46: /*
        !            47:  * NOFREE can be used as the freeProc to Lst_Destroy when the elements are
        !            48:  *     not to be freed.
        !            49:  * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
        !            50:  */
        !            51: #define NOFREE         ((void (*)()) 0)
        !            52: #define NOCOPY         ((ClientData (*)()) 0)
        !            53: 
        !            54: #define LST_CONCNEW    0   /* create new LstNode's when using Lst_Concat */
        !            55: #define LST_CONCLINK   1   /* relink LstNode's when using Lst_Concat */
        !            56: 
        !            57: /*
        !            58:  * Creation/destruction functions
        !            59:  */
        !            60: Lst              Lst_Init();           /* Create a new list */
        !            61: Lst              Lst_Duplicate();      /* Duplicate an existing list */
        !            62: void             Lst_Destroy();        /* Destroy an old one */
        !            63: 
        !            64: int              Lst_Length();         /* Find the length of a list */
        !            65: Boolean                  Lst_IsEmpty();        /* True if list is empty */
        !            66: 
        !            67: /*
        !            68:  * Functions to modify a list
        !            69:  */
        !            70: ReturnStatus     Lst_Insert();         /* Insert an element before another */
        !            71: ReturnStatus     Lst_Append();         /* Insert an element after another */
        !            72: ReturnStatus     Lst_AtFront();        /* Place an element at the front of
        !            73:                                         * a lst. */
        !            74: ReturnStatus     Lst_AtEnd();          /* Place an element at the end of a
        !            75:                                         * lst. */
        !            76: ReturnStatus     Lst_Remove();         /* Remove an element */
        !            77: ReturnStatus     Lst_Replace();        /* Replace a node with a new value */
        !            78: ReturnStatus     Lst_Move();           /* Move an element to another place */
        !            79: ReturnStatus     Lst_Concat();         /* Concatenate two lists */
        !            80: 
        !            81: /*
        !            82:  * Node-specific functions
        !            83:  */
        !            84: LstNode                  Lst_First();          /* Return first element in list */
        !            85: LstNode                  Lst_Last();           /* Return last element in list */
        !            86: LstNode                  Lst_Succ();           /* Return successor to given element */
        !            87: LstNode                  Lst_Pred();           /* Return predecessor to given
        !            88:                                         * element */
        !            89: ClientData       Lst_Datum();          /* Get datum from LstNode */
        !            90: 
        !            91: /*
        !            92:  * Functions for entire lists
        !            93:  */
        !            94: LstNode                  Lst_Find();           /* Find an element in a list */
        !            95: LstNode                  Lst_FindFrom();       /* Find an element starting from
        !            96:                                         * somewhere */
        !            97: LstNode                  Lst_Member();         /* See if the given datum is on the
        !            98:                                         * list. Returns the LstNode containing
        !            99:                                         * the datum */
        !           100: int              Lst_Index();          /* Returns the index of a datum in the
        !           101:                                         * list, starting from 0 */
        !           102: void             Lst_ForEach();        /* Apply a function to all elements of
        !           103:                                         * a lst */
        !           104: void             Lst_ForEachFrom();    /* Apply a function to all elements of
        !           105:                                         * a lst starting from a certain point.
        !           106:                                         * If the list is circular, the
        !           107:                                         * application will wrap around to the
        !           108:                                         * beginning of the list again. */
        !           109: /*
        !           110:  * these functions are for dealing with a list as a table, of sorts.
        !           111:  * An idea of the "current element" is kept and used by all the functions
        !           112:  * between Lst_Open() and Lst_Close().
        !           113:  */
        !           114: ReturnStatus     Lst_Open();           /* Open the list */
        !           115: LstNode                  Lst_Prev();           /* Previous element */
        !           116: LstNode                  Lst_Cur();            /* The current element, please */
        !           117: LstNode                  Lst_Next();           /* Next element please */
        !           118: Boolean                  Lst_IsAtEnd();        /* Done yet? */
        !           119: void             Lst_Close();          /* Finish table access */
        !           120: 
        !           121: /*
        !           122:  * for using the list as a queue
        !           123:  */
        !           124: ReturnStatus     Lst_EnQueue();        /* Place an element at tail of queue */
        !           125: ClientData       Lst_DeQueue();        /* Remove an element from head of
        !           126:                                         * queue */
        !           127: 
        !           128: #endif _LST_H_

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.