~ubuntu-branches/ubuntu/natty/gecode/natty

« back to all changes in this revision

Viewing changes to int/array.cc

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2005-12-24 07:51:25 UTC
  • Revision ID: james.westby@ubuntu.com-20051224075125-klkiqofvbfvusfvt
Tags: upstream-1.0.0.dfsg.1
ImportĀ upstreamĀ versionĀ 1.0.0.dfsg.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Main authors:
 
3
 *     Christian Schulte <schulte@gecode.org>
 
4
 *
 
5
 *  Copyright:
 
6
 *     Christian Schulte, 2002
 
7
 *
 
8
 *  Last modified:
 
9
 *     $Date: 2005-10-19 11:51:16 +0200 (Wed, 19 Oct 2005) $ by $Author: schulte $
 
10
 *     $Revision: 2371 $
 
11
 *
 
12
 *  This file is part of Gecode, the generic constraint
 
13
 *  development environment:
 
14
 *     http://www.gecode.org
 
15
 *
 
16
 *  See the file "LICENSE" for information on usage and
 
17
 *  redistribution of this file, and for a
 
18
 *     DISCLAIMER OF ALL WARRANTIES.
 
19
 *
 
20
 */
 
21
 
 
22
#include "int.hh"
 
23
 
 
24
namespace Gecode {
 
25
 
 
26
  IntVarArray::IntVarArray(Space* home, int n, int min, int max)
 
27
    : VarArray<IntVar>(home,n) {
 
28
    if ((min < Limits::Int::int_min) || (max > Limits::Int::int_max))
 
29
      throw Int::VariableOutOfRangeDomain("IntVarArray");
 
30
    if (min > max)
 
31
      throw Int::VariableEmptyDomain("IntVarArray");
 
32
    for (int i = size(); i--; )
 
33
      x[i].init(home,min,max);
 
34
  }
 
35
 
 
36
  IntVarArray::IntVarArray(Space* home, int n, const IntSet& s)
 
37
    : VarArray<IntVar>(home,n) {
 
38
    if ((s.min() < Limits::Int::int_min) || (s.max() > Limits::Int::int_max))
 
39
      throw Int::VariableOutOfRangeDomain("IntVarArray");
 
40
    if (s.size() == 0)
 
41
      throw Int::VariableEmptyDomain("IntVarArray");
 
42
    for (int i = size(); i--; )
 
43
      x[i].init(home,s);
 
44
  }
 
45
 
 
46
  BoolVarArray::BoolVarArray(Space* home, int n, int min, int max)
 
47
    : IntVarArray(home, n) {
 
48
    if ((min < 0) || (max > 1))
 
49
      throw Int::VariableOutOfRangeDomain("BoolVarArray");
 
50
    if (min > max)
 
51
      throw Int::VariableEmptyDomain("BoolVarArray");
 
52
    for (int i = size(); i--; )
 
53
      x[i].init(home,min,max);
 
54
  }
 
55
 
 
56
 
 
57
}
 
58
 
 
59
 
 
60
// STATISTICS: int-post
 
61