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

org.djutils.serialization.serializers.Pointer Maven / Gradle / Ivy

There is a newer version: 2.2.2
Show newest version
package org.djutils.serialization.serializers;

/**
 * Container for an offset.
 * 

* Copyright (c) 2019-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See DJUTILS License. *

* @author Alexander Verbraeck * @author Peter Knoppers */ public class Pointer { /** Current value of the offset. */ private int offset; /** * Construct a new Pointer with specified initial offset. * @param initialOffset int; the initial offset */ Pointer(final int initialOffset) { this.offset = initialOffset; } /** * Construct a new Pointer with offset 0. */ public Pointer() { this(0); } /** * Retrieve the offset. * @return int; the offset */ public int get() { return this.offset; } /** * Retrieve the current value of offset and increment it. The returned value is the value before applying the * increment. * @param increment int; the amount by which the offset must be incremented * @return int; the offset (before the increment was added) */ public int getAndIncrement(final int increment) { int result = this.offset; this.offset += increment; return result; } /** * Increment the offset. * @param increment int; the amount by which the offset must be incremented */ public void inc(final int increment) { this.offset += increment; } @Override public String toString() { return "Pointer [offset=" + this.offset + "]"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy