// Path: src/main/java/kiwi/propagation/PropagationQueue.java
// public class PropagationQueue {
//   
//   // The propagation queue that contains all the propagators waiting for
//   // propagation. A propagator is considered to be enqueued only if its
//   // enqueued boolean is set to true.
//   private final ArrayDeque<Propagator> queue = new ArrayDeque<Propagator>();
// 
//   /**
//    * Enqueues the propagator for propagation.
//    * 
//    * <p>
//    * This method does nothing if the propagator is already enqueued.
//    * </p>
//    * 
//    * @param propagator the propagator to be scheduled for propagation.
//    */
//   public void enqueue(Propagator propagator) {
//     if (!propagator.enqueued) {
//       queue.addLast(propagator);
//       propagator.enqueued = true;
//     }
//   }
// 
//   /**
//    * Propagates the pending propagators.
//    * 
//    * <p>
//    * Propagate all the propagators contained in the propagation queue.
//    * Propagation is likely to enqueue additional propagators while it is
//    * running. The propagation stops either when the queue is empty, or if a
//    * propagator failed (meaning that the problem is infeasible).
//    * </p>
//    * 
//    * <p>
//    * The method returns true if the propagation succeeded or false if a
//    * propagator failed. The queue is empty at the end of the propagation and all
//    * propagators contained in the queue have their enqueued boolean set to
//    * false.
//    * </p>
//    * 
//    * @return true if propagation succeeded, false otherwise.
//    */
//   public boolean propagate() {
//     boolean feasible = true;
//     while (!queue.isEmpty()) {
//       Propagator propagator = queue.removeFirst();
//       // Dequeue the propagator only if it is not idempotent. This allows the
//       // propagator to enqueue itself back in the propagation queue if it
//       // changed the domain of at least one of its variable.
//       propagator.enqueued = propagator.idempotent;
//       // Propagate only if the problem is still feasible.
//       feasible = feasible && propagator.propagate();
//       // Dequeue the propagator no matter what.
//       propagator.enqueued = false;
//     }
//     return feasible;
//   }
// }
// 
// Path: src/main/java/kiwi/propagation/Propagator.java
// public abstract class Propagator {
// 
//   /** 
//    * Indicates if the propagator is contained in the propagation queue. 
//    */
//   protected boolean enqueued;
// 
//   /** 
//    * Indicates if the propagator might need to be called again just after 
//    * propagation. 
//    */  
//   protected boolean idempotent;
// 
//   /**
//    * Initializes the propagator and performs its initial propagation
//    * 
//    * @return false if the propagation failed.
//    */
//   public abstract boolean setup();
// 
//   /**
//    * Propagates the last domain changes
//    * 
//    * @return false if the propagation failed.
//    */
//   public abstract boolean propagate();
// }
// 
// Path: src/main/java/kiwi/trail/Trail.java
// public class Trail {
// 
//   private long timestamp = 0L;
// 
//   private final Stack<Change> changes = new Stack<Change>();
//   private final StackInt levels = new StackInt();
// 
//   public long getTimestamp() {
//     return timestamp;
//   }
// 
//   public void store(Change change) {
//     changes.push(change);
//   }
// 
//   public void newLevel() {
//     levels.push(changes.getSize());
//     timestamp++;
//   }
// 
//   public void undoLevel() {
//     if (levels.getSize() > 0)
//       undoUntil(levels.pop());
//     timestamp++;
//   }
// 
//   public void undoAll() {
//     while (levels.getSize() > 0) {
//       undoUntil(levels.pop());
//     }
//     timestamp++;
//   }
// 
//   private void undoUntil(int size) {
//     while (changes.getSize() > size) {
//       changes.pop().undo();
//     }
//   }
// }


import kiwi.propagation.PropagationQueue;
import kiwi.propagation.Propagator;
import kiwi.trail.Trail;
/*
 * Copyright 2016, Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package kiwi.variable;


public class IntVarSingleton extends IntVar {

  private final PropagationQueue pQueue;
// Path: src/main/java/kiwi/propagation/PropagationQueue.java
// public class PropagationQueue {
//   
//   // The propagation queue that contains all the propagators waiting for
//   // propagation. A propagator is considered to be enqueued only if its
//   // enqueued boolean is set to true.
//   private final ArrayDeque<Propagator> queue = new ArrayDeque<Propagator>();
// 
//   /**
//    * Enqueues the propagator for propagation.
//    * 
//    * <p>
//    * This method does nothing if the propagator is already enqueued.
//    * </p>
//    * 
//    * @param propagator the propagator to be scheduled for propagation.
//    */
//   public void enqueue(Propagator propagator) {
//     if (!propagator.enqueued) {
//       queue.addLast(propagator);
//       propagator.enqueued = true;
//     }
//   }
// 
//   /**
//    * Propagates the pending propagators.
//    * 
//    * <p>
//    * Propagate all the propagators contained in the propagation queue.
//    * Propagation is likely to enqueue additional propagators while it is
//    * running. The propagation stops either when the queue is empty, or if a
//    * propagator failed (meaning that the problem is infeasible).
//    * </p>
//    * 
//    * <p>
//    * The method returns true if the propagation succeeded or false if a
//    * propagator failed. The queue is empty at the end of the propagation and all
//    * propagators contained in the queue have their enqueued boolean set to
//    * false.
//    * </p>
//    * 
//    * @return true if propagation succeeded, false otherwise.
//    */
//   public boolean propagate() {
//     boolean feasible = true;
//     while (!queue.isEmpty()) {
//       Propagator propagator = queue.removeFirst();
//       // Dequeue the propagator only if it is not idempotent. This allows the
//       // propagator to enqueue itself back in the propagation queue if it
//       // changed the domain of at least one of its variable.
//       propagator.enqueued = propagator.idempotent;
//       // Propagate only if the problem is still feasible.
//       feasible = feasible && propagator.propagate();
//       // Dequeue the propagator no matter what.
//       propagator.enqueued = false;
//     }
//     return feasible;
//   }
// }
// 
// Path: src/main/java/kiwi/propagation/Propagator.java
// public abstract class Propagator {
// 
//   /** 
//    * Indicates if the propagator is contained in the propagation queue. 
//    */
//   protected boolean enqueued;
// 
//   /** 
//    * Indicates if the propagator might need to be called again just after 
//    * propagation. 
//    */  
//   protected boolean idempotent;
// 
//   /**
//    * Initializes the propagator and performs its initial propagation
//    * 
//    * @return false if the propagation failed.
//    */
//   public abstract boolean setup();
// 
//   /**
//    * Propagates the last domain changes
//    * 
//    * @return false if the propagation failed.
//    */
//   public abstract boolean propagate();
// }
// 
// Path: src/main/java/kiwi/trail/Trail.java
// public class Trail {
// 
//   private long timestamp = 0L;
// 
//   private final Stack<Change> changes = new Stack<Change>();
//   private final StackInt levels = new StackInt();
// 
//   public long getTimestamp() {
//     return timestamp;
//   }
// 
//   public void store(Change change) {
//     changes.push(change);
//   }
// 
//   public void newLevel() {
//     levels.push(changes.getSize());
//     timestamp++;
//   }
// 
//   public void undoLevel() {
//     if (levels.getSize() > 0)
//       undoUntil(levels.pop());
//     timestamp++;
//   }
// 
//   public void undoAll() {
//     while (levels.getSize() > 0) {
//       undoUntil(levels.pop());
//     }
//     timestamp++;
//   }
// 
//   private void undoUntil(int size) {
//     while (changes.getSize() > size) {
//       changes.pop().undo();
//     }
//   }
// }


// Path: src/main/java/kiwi/variable/IntVarSingleton.java
import kiwi.propagation.PropagationQueue;
import kiwi.propagation.Propagator;
import kiwi.trail.Trail;

/*
 * Copyright 2016, Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package kiwi.variable;


public class IntVarSingleton extends IntVar {

  private final PropagationQueue pQueue;
  private final Trail trail;