java.lang.Object
org.klojang.util.MutableInt
The ubiquitous mutable-integer class.
-
Constructor Summary
ConstructorDescriptionInstantiates aMutableInt
with an initial value of 0 (zero).MutableInt
(int value) Instantiates aMutableInt
with the specified initial value.MutableInt
(MutableInt other) Instantiates aMutableInt
initialized to the current value of another instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
eq
(int j) Corresponds to the==
(equals) operation.boolean
eq
(MutableInt other) Corresponds to the==
(equals) operation.boolean
int
get()
Returns the current value of thisMutableInt
.boolean
gt
(int j) Corresponds to the>
(greater than) operation.boolean
gt
(MutableInt other) Corresponds to the>
(greater than) operation.boolean
gte
(int j) Corresponds to the>=
(greater or equal) operation.boolean
gte
(MutableInt other) Corresponds to the>=
(greater or equal) operation.int
hashCode()
Returns the current value of this instanceboolean
lt
(int j) Corresponds to the<
(less than) operation.boolean
lt
(MutableInt other) Corresponds to the<
(less than) operation.boolean
lte
(int j) Corresponds to the<=
(less or equal) operation.boolean
lte
(MutableInt other) Corresponds to the<=
(less or equal) operation.int
minIs
(int j) Corresponds to the-=
(minus-is) operation.int
minIs
(MutableInt other) Corresponds to the-=
(minus-is) operation.int
mm()
Corresponds to the--
postfix operator (i--
).int
mmi()
Corresponds to the--
prefix operator (--i
).boolean
ne
(int j) Corresponds to the!=
(not equals) operation.boolean
ne
(MutableInt other) Corresponds to the!=
(not equals) operation.int
plusIs
(int j) Corresponds to the+=
operation.int
plusIs
(MutableInt other) Corresponds to the+=
operation.int
pp()
Corresponds to the++
postfix operator (i++
).int
ppi()
Corresponds to the++
prefix operator (++i
).int
reset()
Sets the value to 0 (zero).int
set
(int j) Corresponds to the assignment operation (i = j
).int
set
(MutableInt other) Corresponds to the assignment operation (i = j
).toString()
Returns the string representation of the current value.
-
Constructor Details
-
MutableInt
public MutableInt()Instantiates aMutableInt
with an initial value of 0 (zero). -
MutableInt
public MutableInt(int value) Instantiates aMutableInt
with the specified initial value.- Parameters:
value
- The initial value of this instance
-
MutableInt
Instantiates aMutableInt
initialized to the current value of another instance.- Parameters:
other
- The instance used to initialize this instance.
-
-
Method Details
-
get
public int get()Returns the current value of thisMutableInt
.- Returns:
- The current value of this
MutableInt
-
pp
public int pp()Corresponds to the++
postfix operator (i++
).- Returns:
- The original value (before incrementation)
-
ppi
public int ppi()Corresponds to the++
prefix operator (++i
).- Returns:
- The incremented value (after incrementation)
-
mm
public int mm()Corresponds to the--
postfix operator (i--
).- Returns:
- The original value
-
mmi
public int mmi()Corresponds to the--
prefix operator (--i
).- Returns:
- The decremented value
-
plusIs
public int plusIs(int j) Corresponds to the+=
operation.- Parameters:
j
- The value to add- Returns:
- The new value
-
plusIs
Corresponds to the+=
operation.- Parameters:
other
- The value the add- Returns:
- The new value
-
minIs
public int minIs(int j) Corresponds to the-=
(minus-is) operation.- Parameters:
j
- The value to subtract- Returns:
- The new value
-
minIs
Corresponds to the-=
(minus-is) operation.- Parameters:
other
- The value to subtract- Returns:
- The new value
-
set
public int set(int j) Corresponds to the assignment operation (i = j
).- Parameters:
j
- The value to assign to thisMutableInt
- Returns:
- The new value
-
set
Corresponds to the assignment operation (i = j
).- Parameters:
other
- The value to assign to thisMutableInt
- Returns:
- The new value
-
eq
public boolean eq(int j) Corresponds to the==
(equals) operation.- Parameters:
j
- The value to compare this instance with- Returns:
true
if equal,false
otherwise
-
eq
Corresponds to the==
(equals) operation.- Parameters:
other
- The value to compare this instance with- Returns:
true
if equal,false
otherwise
-
ne
public boolean ne(int j) Corresponds to the!=
(not equals) operation.- Parameters:
j
- The value to compare this instance with- Returns:
true
if not equal,false
otherwise
-
ne
Corresponds to the!=
(not equals) operation.- Parameters:
other
- The value to compare this instance with- Returns:
true
if equal,false
otherwise
-
gt
public boolean gt(int j) Corresponds to the>
(greater than) operation.- Parameters:
j
- The value to compare this instance with- Returns:
true
if this instance has a value greater than the specified value,false
otherwise
-
gt
Corresponds to the>
(greater than) operation.- Parameters:
other
- The value to compare this instance with- Returns:
true
if this instance has a value greater than the specified value,false
otherwise
-
lt
public boolean lt(int j) Corresponds to the<
(less than) operation.- Parameters:
j
- The value to compare this instance with- Returns:
true
if this instance has a value less than the specified value,false
otherwise
-
lt
Corresponds to the<
(less than) operation.- Parameters:
other
- The value to compare this instance with- Returns:
true
if this instance has a value less than the specified value,false
otherwise
-
gte
public boolean gte(int j) Corresponds to the>=
(greater or equal) operation.- Parameters:
j
- The value to compare this instance with- Returns:
true
if this instance has a value greater than, or equal to the specified value,false
otherwise
-
gte
Corresponds to the>=
(greater or equal) operation.- Parameters:
other
- The value to compare this instance with- Returns:
true
if this instance has a value greater than, or equal to the specified value,false
otherwise
-
lte
public boolean lte(int j) Corresponds to the<=
(less or equal) operation.- Parameters:
j
- The value to compare this instance with- Returns:
true
if this instance has a value less than, or equal to the specified value,false
otherwise
-
lte
Corresponds to the<=
(less or equal) operation.- Parameters:
other
- The value to compare this instance with- Returns:
true
if this instance has a value less than, or equal to the specified value,false
otherwise
-
reset
public int reset()Sets the value to 0 (zero).- Returns:
- 0 (zero)
-
hashCode
public int hashCode()Returns the current value of this instance -
equals
-
toString
Returns the string representation of the current value.
-