Package org.djutils.base
Class MutableInt
- java.lang.Object
-
- org.djutils.base.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 voiddec()Decrement the modifiable int with 1.voiddec(int decrement)Decrement the modifiable int with a value.voiddiv(int divisor)Divide the modifiable int by a value.booleanequals(Object obj)intget()inthashCode()voidinc()Increment the modifiable int with 1.voidinc(int increment)Increment the modifiable int with a value.voidmul(int multiplier)Increment the modifiable int with a value.voidset(int newValue)set the mutable integer to a new value.StringtoString()
-
-
-
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
-
-