source: trunk/tools/common/kList.h

Last change on this file was 8003, checked in by bird, 24 years ago

New kFile* classes; now in sync with os2tools.

File size: 2.8 KB
Line 
1/* $Id: kList.h,v 1.4 2002-02-24 02:47:28 bird Exp $ */
2/*
3 * Simple list and sorted list template class.
4 *
5 * Copyright (c) 1999 knut st. osmundsen
6 *
7 */
8#ifndef _lkList_h_
9#define _lkList_h_
10
11
12 /**
13 * List entry parent function.
14 * @purpose Serve as a base class for list entries.
15 * @author knut st. osmundsen
16 */
17 class kListEntry
18 {
19 private:
20 kListEntry *pNext;
21
22 public:
23
24 /**
25 * Sets the nextpointer.
26 * @param pNewNext New value of next pointer.
27 */
28 void setNext(kListEntry *pNewNext)
29 {
30 pNext = pNewNext;
31 }
32
33
34 /**
35 * Get next pointer value.
36 * @returns Next pointer.
37 */
38 kListEntry *getNext(void)
39 {
40 return pNext;
41 }
42 };
43
44
45
46 /**
47 * List template. Not Implemented yet.
48 * @author knut st. osmundsen
49 */
50 template <class kEntry>
51 class kList
52 {
53 private:
54 kEntry *pFirst;
55 kEntry *pLast;
56 unsigned long cEntries;
57
58 public:
59 kList(void);
60 ~kList(void);
61
62 void destroy(void);
63 void insert(kEntry *pEntry);
64 kEntry * getFirst(void) const;
65 kEntry * getLast(void) const;
66 unsigned long getCount(void) const;
67 };
68
69
70 /**
71 * List entry parent function.
72 * @purpose Serve as a base class for list sorted entries.
73 * @author knut st. osmundsen
74 */
75 class kSortedListEntry : public kListEntry
76 {
77 public:
78 #if 0 //MUST BE IMPLEMENTED!
79 virtual KBOOL operator==(const k..Entry &entry) const = 0;
80 virtual KBOOL operator!=(const k..Entry &entry) const = 0;
81 virtual KBOOL operator< (const k..Entry &entry) const = 0;
82 virtual KBOOL operator<=(const k..Entry &entry) const = 0;
83 virtual KBOOL operator> (const k..Entry &entry) const = 0;
84 virtual KBOOL operator>=(const k..Entry &entry) const = 0;
85 #endif
86 };
87
88
89 /**
90 * Sorted List template.
91 * @author knut st. osmundsen
92 */
93 template <class kEntry>
94 class kSortedList
95 {
96 private:
97 kEntry *pFirst;
98 kEntry *pLast;
99 unsigned long cEntries;
100
101 public:
102 kSortedList(void);
103 ~kSortedList(void);
104
105 void destroy(void);
106 void insert(kEntry *pEntry);
107 kEntry * get(const kEntry &entry) const;
108 kEntry * getFirst(void) const;
109 kEntry * getLast(void) const;
110 unsigned long getCount(void) const;
111 };
112
113
114#endif
115
116
Note: See TracBrowser for help on using the repository browser.