Generated on Thu Mar 22 10:39:43 2012 for Gecode by doxygen 1.6.3

range-list.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Contributing authors:
00007  *     Guido Tack <tack@gecode.org>
00008  *
00009  *  Copyright:
00010  *     Christian Schulte, 2004
00011  *     Guido Tack, 2004
00012  *
00013  *  Last modified:
00014  *     $Date: 2011-05-11 12:44:17 +0200 (Wed, 11 May 2011) $ by $Author: tack $
00015  *     $Revision: 12001 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 namespace Gecode {
00043 
00053   class RangeList : public FreeList {
00054   protected:
00056     int        _min;
00058     int        _max;
00059   public:
00061 
00062 
00063     RangeList(void);
00065     RangeList(int min, int max, RangeList* n);
00067 
00069 
00070 
00071     int min(void) const;
00073     int max(void) const;
00075     unsigned int width(void) const;
00076 
00078     RangeList* next(void) const;
00080 
00082 
00083 
00084     void min(int n);
00086     void max(int n);
00088     void next(RangeList* n);
00090 
00092 
00093 
00096     void dispose(Space& home, RangeList* l);
00097 
00099     static void* operator new(size_t s, Space& home);
00101     static void* operator new(size_t s, void* p);
00103     static void  operator delete(void*);
00105     static void  operator delete(void*, Space& home);
00107     static void  operator delete(void*, void*);
00109   };
00110 
00111   /*
00112    * Range lists
00113    *
00114    */
00115 
00116   forceinline
00117   RangeList::RangeList(void) {}
00118 
00119   forceinline
00120   RangeList::RangeList(int min, int max, RangeList* n)
00121     : FreeList(n), _min(min), _max(max) {}
00122 
00123   forceinline RangeList*
00124   RangeList::next() const {
00125     return static_cast<RangeList*>(FreeList::next());
00126   }
00127 
00128   forceinline void
00129   RangeList::min(int n) {
00130     _min = n;
00131   }
00132   forceinline void
00133   RangeList::max(int n) {
00134     _max = n;
00135   }
00136   forceinline void
00137   RangeList::next(RangeList* n) {
00138     FreeList::next(n);
00139   }
00140 
00141   forceinline int
00142   RangeList::min(void) const {
00143     return _min;
00144   }
00145   forceinline int
00146   RangeList::max(void) const {
00147     return _max;
00148   }
00149   forceinline unsigned int
00150   RangeList::width(void) const {
00151     return static_cast<unsigned int>(_max - _min + 1);
00152   }
00153 
00154 
00155   forceinline void
00156   RangeList::operator delete(void*) {}
00157 
00158   forceinline void
00159   RangeList::operator delete(void*, Space&) {
00160     GECODE_NEVER;
00161   }
00162 
00163   forceinline void
00164   RangeList::operator delete(void*, void*) {
00165     GECODE_NEVER;
00166   }
00167 
00168   forceinline void*
00169   RangeList::operator new(size_t, Space& home) {
00170     return home.fl_alloc<sizeof(RangeList)>();
00171   }
00172 
00173   forceinline void*
00174   RangeList::operator new(size_t, void* p) {
00175     return p;
00176   }
00177 
00178   forceinline void
00179   RangeList::dispose(Space& home, RangeList* l) {
00180     home.fl_dispose<sizeof(RangeList)>(this,l);
00181   }
00182 
00183 }
00184 // STATISTICS: kernel-other