Class MutableLong

java.lang.Object
org.djutils.base.MutableLong

public class MutableLong extends Object
A simple version of a mutable long with get() and set(long) functions.

Copyright (c) 2023-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Alexander Verbraeck
  • Constructor Summary

    Constructors
    Constructor
    Description
    MutableLong(long value)
    Initialize the mutable long with a value.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dec()
    Decrement the modifiable long with 1.
    void
    dec(long decrement)
    Decrement the modifiable long with a value.
    void
    div(long divisor)
    Divide the modifiable long by a value.
    boolean
     
    long
    get()
     
    int
     
    void
    inc()
    Increment the modifiable long with 1.
    void
    inc(long increment)
    Increment the modifiable long with a value.
    void
    mul(long multiplier)
    Increment the modifiable long with a value.
    void
    set(long newValue)
    set the mutable long to a new value.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MutableLong

      public MutableLong(long value)
      Initialize the mutable long with a value.
      Parameters:
      value - long; the initial value of the mutable long
  • Method Details

    • set

      public void set(long newValue)
      set the mutable long to a new value.
      Parameters:
      newValue - long; the new value of the mutable long
    • get

      public long get()
      Returns:
      long; the current value of the mutable long
    • inc

      public void inc(long increment)
      Increment the modifiable long with a value.
      Parameters:
      increment - long; the value to increment the modifiable long with
    • inc

      public void inc()
      Increment the modifiable long with 1.
    • dec

      public void dec(long decrement)
      Decrement the modifiable long with a value.
      Parameters:
      decrement - long; the value to decrement the modifiable long with
    • dec

      public void dec()
      Decrement the modifiable long with 1.
    • mul

      public void mul(long multiplier)
      Increment the modifiable long with a value.
      Parameters:
      multiplier - long; the value to multiply the modifiable long with
    • div

      public void div(long divisor)
      Divide the modifiable long by a value.
      Parameters:
      divisor - long; the value to divide the modifiable long by
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object