Scenario:
1) I have a long state variable that may or may not be set.
2) This long variable has valid values โโfrom Long.MIN_VALUE to Long.MAX_VALUE, including zero
3) This is performance sensitive code, so I don't want to use a long shell type
How do I write down the โinstalledโ type of verification for a long time? Should I add a second boolean to check if long is valid or not? It seems messy. I know that I could use a long shell here, but it seems like a performance waste creating so many objects and checking for zero.
Pseudocode (this is what I want):
class foo {
long someLong = NaN;
public reset() {
someLong = NaN;
}
public doSomethingElse() {
if(someLong !=NaN) {
reset();
}
}
public doSomeStuff() {
if(someLong == NaN) {
someLong =
}
}
}
}
source
share