BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
set_1.h
Go to the documentation of this file.
1 // ============================================================================
2 // Project: Deductive Database
3 // Filename: set_1.h
4 // Purpose: Set of rows with one int column (relation with binding b)
5 // Last Change: 01.08.2017
6 // Language: C++
7 // EMail: brass@informatik.uni-halle.de
8 // WWW: http://www.informatik.uni-halle.de/~brass/
9 // Address: Feldschloesschen 15, D-06120 Halle (Saale), GERMANY
10 // Copyright: (c) 2015-2017 by Stefan Brass
11 // License: See file "LICENSE" for copying conditions.
12 // Note: There is no warranty at all - this code may contain bugs.
13 // ============================================================================
14 
15 
22 //=============================================================================
23 // Include File Frame:
24 //=============================================================================
25 
26 #ifndef SET_1_INCLUDED
27 #define SET_1_INCLUDED
28 
29 //=============================================================================
30 // Used Types and Macros:
31 //=============================================================================
32 
33 #ifndef VER_INCLUDED
34 #include "../base/ver.h"
35 #endif
36 
37 #ifndef STR_INCLUDED
38 #include "../base/str.h"
39 #endif
40 
41 #ifndef CHECK_INCLUDED
42 #include "../base/check.h"
43 #endif
44 
45 #ifndef ROW_1_INCLUDED
46 #include "../rel/row_1.h"
47 #endif
48 
49 #ifndef SET_INCLUDED
50 #include "../rel/set.h"
51 #endif
52 
53 
54 //=============================================================================
55 // Set of Rows with one int column / Relation with binding pattern b:
56 //=============================================================================
57 
58 class set_1_c: public set_c<row_1_c> {
59 
60  public:
61 
62 //-----------------------------------------------------------------------------
63 // Constructor, Destructor:
64 //-----------------------------------------------------------------------------
65 
66  // Constructor:
67  set_1_c(str_t set_name);
68 
69  // Destructor:
70  ~set_1_c();
71 
72 //-----------------------------------------------------------------------------
73 // Copy-constructor and assignment operator are not supported for this class:
74 //-----------------------------------------------------------------------------
75 
76  private:
77 
78  set_1_c(const set_1_c& obj); // Not implemented
79  set_1_c& operator=(const set_1_c& obj); // Not implemented
80 
81 
82 //=============================================================================
83 // (Object) Methods:
84 //=============================================================================
85 
86  public:
87 
88 //-----------------------------------------------------------------------------
89 // insert: Insert an element into the set (returns true if successful).
90 //-----------------------------------------------------------------------------
91 
92  // This method returns true if the row was not already in the set
93  // and was successfully inserted (i.e. if it is not a duplicate).
94  // It returns false if the row was already in the set (duplicate).
95  // It also returns false if it was impossible to insert the element
96  // because there was not enough memory.
97 
98  inline bool insert(int col1) {
99  return set_c<row_1_c>::insert(row_1_c(col1));
100  }
101 
102 //-----------------------------------------------------------------------------
103 // contains: Check whether an element is contained in the set.
104 //-----------------------------------------------------------------------------
105 
106  inline bool contains(int col1) const {
107  return set_c<row_1_c>::contains(row_1_c(col1));
108  }
109 
110 //=============================================================================
111 // End of Class Template:
112 //=============================================================================
113 
114 };
115 
116 
117 //-----------------------------------------------------------------------------
118 // Define pointer type:
119 //-----------------------------------------------------------------------------
120 
121 typedef set_1_c *set_1_t;
122 
123 //-----------------------------------------------------------------------------
124 // Define null pointer:
125 //-----------------------------------------------------------------------------
126 
127 #define SET_1_NULL (static_cast<set_1_t>(0))
128 
129 
130 //=============================================================================
131 // End of Include File:
132 //=============================================================================
133 
134 #endif
135 
Definition: set_1.h:58
const char * str_t
Definition: str.h:41
Definition: row_1.h:60
Definition: set.h:110