Class MutableInt


  • public class MutableInt
    extends Object
    A simple version of a mutable integer with get() and set(int) functions.

    Copyright (c) 2023-2023 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
      MutableInt​(int value)
      Initialize the mutable integer with a value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dec()
      Decrement the modifiable int with 1.
      void dec​(int decrement)
      Decrement the modifiable int with a value.
      void div​(int divisor)
      Divide the modifiable int by a value.
      boolean equals​(Object obj)
      int get()  
      int hashCode()
      void inc()
      Increment the modifiable int with 1.
      void inc​(int increment)
      Increment the modifiable int with a value.
      void mul​(int multiplier)
      Increment the modifiable int with a value.
      void set​(int newValue)
      set the mutable integer to a new value.
      String toString()
    • Constructor Detail

      • MutableInt

        public MutableInt​(int value)
        Initialize the mutable integer with a value.
        Parameters:
        value - int; the initial value of the mutable integer
    • Method Detail

      • set

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

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

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

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

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

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

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

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

        public int hashCode()
        Overrides:
        hashCode in class Object