home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!julienas!sophia!modja.inria.fr!beust
- From: beust@modja.inria.fr (Cedric Beust)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Small database package
- Message-ID: <35892@sophia.inria.fr>
- Date: 10 Dec 92 09:33:36 GMT
- Sender: news@sophia.inria.fr
- Organization: University of Nice Sophia-Antipolis, France
- Lines: 87
-
-
- While writing a program, I happened to need badly a generic way
- to handle data. So I decided to write a small generic module
- that helped me a great deal. It occured to me that if someone
- had posted this kind of thing on Usenet, it would have saved
- me some development time. That's why I'm posting the header
- of the module. It should be enough for any programmers to decide
- whether they need it or not.
-
- Depending on the interest, I'll wrap a distribution and make it
- available on ftp site (or by mail, it's very short), so let me
- know if you're interested.
-
- I won't insist on the Genericity interest, nor the "abstract
- type" concept. All you have to know is that you can change
- the implementation to improve it and you won't have to modify
- your programs...
-
- One last point : the database module is completely dynamic and
- will only be limited by your memory.
-
- The excerpt from the header file follows.
-
-
- --
- Cedric BEUST, beust@sa.inria.fr, Bull Research Koala proj, KoalaBus & xforum
- Pho:(33) 93.65.78.07(.66 Fax), INRIA, B.P.93 - 06902 Sophia Antipolis, FRANCE.
-
-
-
- /* Generic module to handle dynamically allocated database */
-
- DataBase
- DB_NewDataBase(int size);
- /* Initialize a new database, which objects have size 'size' */
- /* Alter the internal pointer */
-
- Bool
- DB_EndOfDataBase(DataBase db);
- /* True if we reached the end of the database */
-
- void
- DB_ClearDataBase(DataBase db);
- /* Clear the database */
-
- Bool
- DB_AddEntry(DataBase db, Generic entry);
- /* Add the following entry into the database */
- /* Return 0 if the operation was successful */
-
- Bool
- DB_RemoveEntry(DataBase db, Generic entry);
- /* Remove the specified entry */
- /* Return 0 if the operation was successful */
-
- Bool
- DB_RemoveNthEntry(DataBase db, int n);
- /* Remove the nth DB_NextEntry from the database (0 = first entry) */
- /* Return 0 if the operation was successful */
-
- Bool
- DB_ReplaceEntry(DataBase db, Generic old, Generic new);
- /* Replace the old entry with the new one */
- /* Return 0 if the operation was successful */
-
- void
- DB_Rewind(DataBase db);
- /* Rewind the database so that a subsequent NextEntry returns the */
- /* first occupied element */
-
- Generic
- DB_NextEntry(DataBase db);
- /* Return the next entry, or NULL if we reached the end of the database */
-
- Generic
- DB_NthEntry(DataBase db, int n);
- /* Return the nth "DB_NextEntry" of the database (0 = first entry) */
-
- int
- DB_Count(DataBase db);
- /* Return the number of entries in the databae */
-
- void
- DB_Sort(DataBase db, int (* compareFunction)(Generic a, Generic b));
- /* Sort the database, so that */
- /* compareFunction(DB_NextEntry(db), DB_NextEntry(db)) < 0 */
-
-