All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.chocosolver.solver.variables.delta.OneValueDelta Maven / Gradle / Ivy

There is a newer version: 4.10.17
Show newest version
/*
 * This file is part of choco-solver, http://choco-solver.org/
 *
 * Copyright (c) 2022, IMT Atlantique. All rights reserved.
 *
 * Licensed under the BSD 4-clause license.
 *
 * See LICENSE file in the project root for full license information.
 */
package org.chocosolver.solver.variables.delta;

import org.chocosolver.memory.IEnvironment;
import org.chocosolver.solver.ICause;
import org.chocosolver.solver.search.loop.TimeStampedObject;

/**
 * 
* * @author Charles Prud'homme * @since 18 nov. 2010 */ public final class OneValueDelta extends TimeStampedObject implements IEnumDelta { private int value; private ICause cause; private boolean set; public OneValueDelta(IEnvironment environment) { super(environment); } @Override public void lazyClear() { if (needReset()) { set = false; resetStamp(); } } @Override public void add(int value, ICause cause) { lazyClear(); this.value = value; this.cause = cause; set = true; } @Override public int get(int idx) { if (idx < 1) { return value; } else { throw new IndexOutOfBoundsException("OneValueDelta#get(): size must be checked before!"); } } @Override public ICause getCause(int idx) { if (idx < 1) { return cause; } else { throw new IndexOutOfBoundsException("OneValueDelta#get(): size must be checked before!"); } } @Override public int size() { return set ? 1 : 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy