BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
set_2s.h
Go to the documentation of this file.
1 // ============================================================================
2 // Project: Deductive Database
3 // Filename: set_2s.h
4 // Purpose: Set of rows with two int columns (relation with binding bb)
5 // Last Change: 04.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) 2016-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_2S_INCLUDED
27 #define SET_2S_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_2_INCLUDED
46 #include "row_2.h"
47 #endif
48 
49 #ifndef SET_S_INCLUDED
50 #include "set_s.h"
51 #endif
52 
53 
54 //=============================================================================
55 // Set of Rows with two int columns / Relation with binding pattern bb:
56 //=============================================================================
57 
58 class set_2s_c: public set_s_c<row_2_c> {
59 
60  public:
61 
62 //-----------------------------------------------------------------------------
63 // Constructor, Destructor:
64 //-----------------------------------------------------------------------------
65 
66  // Constructor:
67  set_2s_c(str_t set_name);
68 
69  // Destructor:
70  ~set_2s_c();
71 
72 //-----------------------------------------------------------------------------
73 // Copy-constructor and assignment operator are not supported for this class:
74 //-----------------------------------------------------------------------------
75 
76  private:
77 
78  set_2s_c(const set_2s_c& obj); // Not implemented
79  set_2s_c& operator=(const set_2s_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, int col2) {
99  return set_s_c<row_2_c>::insert(row_2_c(col1, col2));
100  }
101 
102 //-----------------------------------------------------------------------------
103 // contains: Check whether an element is contained in the set.
104 //-----------------------------------------------------------------------------
105 
106  inline bool contains(int col1, int col2) const {
107  return set_s_c<row_2_c>::contains(row_2_c(col1, col2));
108  }
109 
110 //=============================================================================
111 // End of Class Template:
112 //=============================================================================
113 
114 };
115 
116 
117 //-----------------------------------------------------------------------------
118 // Define pointer type:
119 //-----------------------------------------------------------------------------
120 
121 typedef set_2s_c *set_2s_t;
122 
123 //-----------------------------------------------------------------------------
124 // Define null pointer:
125 //-----------------------------------------------------------------------------
126 
127 #define SET_2S_NULL (static_cast<set_2s_t>(0))
128 
129 
130 //=============================================================================
131 // End of Include File:
132 //=============================================================================
133 
134 #endif
135 
Definition: set_s.h:96
const char * str_t
Definition: str.h:41
Definition: row_2.h:66
Definition: set_2s.h:58
Tuple/Table Row with two integer columns.
Set of tuples (binding pattern "b..b"): Using C++ Standard Template Library.