Generated on for Gecode by doxygen 1.18.0
growable-int-set.hh
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main author:
4 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
5 *
6 * Copyright:
7 * Mikael Zayenz Lagerkvist, 2026
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.dev
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#ifndef GECODE_INT_GROWABLE_INT_SET_HH
35#define GECODE_INT_GROWABLE_INT_SET_HH
36
37#include <gecode/int.hh>
38#include <limits>
39
40namespace Gecode { namespace Int {
41
43
45 class GrowableIntSet {
47 private:
48 struct Range {
49 int min;
50 int max;
51 Range(void) {}
52 };
53 Range* _ranges;
54 unsigned int _count;
55 unsigned int _capacity;
56
58 static unsigned int max_capacity(void);
60 void reserve(Space& home, unsigned int required);
62 unsigned int first_max_ge(int value) const;
64 void add(Space& home, int min, int max);
65
66 GrowableIntSet(const GrowableIntSet&) = delete;
67 GrowableIntSet& operator =(const GrowableIntSet&) = delete;
68 public:
70 GrowableIntSet(void);
72 bool in(int value) const;
78 template<class I> void add_r(Space& home, I added);
80 void update(Space& home, const GrowableIntSet& source);
82 void dispose(Space& home);
83 };
84
87 private:
88 const GrowableIntSet::Range* current;
89 const GrowableIntSet::Range* end;
90 public:
92 bool operator ()(void) const;
93 void operator ++(void);
94 int min(void) const;
95 int max(void) const;
96 unsigned int width(void) const;
97 };
98
99}}
100
102
103#endif
104
105// STATISTICS: int-other
Borrowed forward iterator over a growable set's ranges.
GrowableIntSetRanges(const GrowableIntSet &set)
A Space-owned set of integer values with growable canonical range storage.
void dispose(Space &home)
Return allocated storage to home.
void update(Space &home, const GrowableIntSet &source)
Copy exactly the live ranges into independent storage in home.
bool in(int value) const
Test membership.
void add_r(Space &home, I added)
Add the ranges from a copyable, independent canonical iterator.
GrowableIntSet(void)
Initialize an empty set.
Computation spaces.
Definition core.hpp:1787
Finite domain integers.
Definition lastval.hh:52
Gecode toplevel namespace
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .