001package org.cpsolver.ifs.util;
002
003/**
004 * Counter.
005 * 
006 * @author  Tomáš Müller
007 * @version IFS 1.3 (Iterative Forward Search)<br>
008 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
009 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
010 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
011 * <br>
012 *          This library is free software; you can redistribute it and/or modify
013 *          it under the terms of the GNU Lesser General Public License as
014 *          published by the Free Software Foundation; either version 3 of the
015 *          License, or (at your option) any later version. <br>
016 * <br>
017 *          This library is distributed in the hope that it will be useful, but
018 *          WITHOUT ANY WARRANTY; without even the implied warranty of
019 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
020 *          Lesser General Public License for more details. <br>
021 * <br>
022 *          You should have received a copy of the GNU Lesser General Public
023 *          License along with this library; if not see
024 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
025 */
026public class Counter {
027    private long iValue = 0;
028
029    /** Set counter 
030     * @param value counter value
031     **/
032    public void set(long value) {
033        iValue = value;
034    }
035
036    /** Returns current value 
037     * @return counter value
038     **/
039    public long get() {
040        return iValue;
041    }
042
043    /** Increment counter
044     * @param value counter increment
045     **/
046    public void inc(long value) {
047        iValue += value;
048    }
049
050    /** Decrement counter
051     * @param value counter decrement
052     **/
053    public void dec(long value) {
054        iValue -= value;
055    }
056}