Reputation: 26607
Are there any issues that I need to think off before allowing for negative range to allot ids to entities in my application ?
Any downsides of storing negative id range when the positive range is used up in my application ?
Upvotes: 2
Views: 99
Reputation: 8204
One downside of this that I found was if you ever need to wander into performance territory.
One of the systems I had to work on had to do a LOT of map look ups based on ID. The maps it was looking at had > 400 million entries, and there were multiple maps. A map based on an Integer key was where I started. However, for memory efficiency AND speed I ended up switching over to an array, where the index was the key. Working with negative numbers would inhibit this.
Another limitations would be in any type of BitSet work if you had to do any Set mathematics on the IDs.
That being said, this is a fairly narrow use case.
Upvotes: 3
Reputation: 12835
Do you have any code that looks like this:
int id = FindRecord();
if ( id > 0 )
{
Success();
}
else
{
Failure();
}
If so, you'll need to refactor it.
Upvotes: 1