J
James Aguilar
I have a class that's holding a list of pointers to pointers. It is an
implementation of an open addressed hashmap. It is homework, but I only
want help on this specific issue. Please do not tell me anything about
hashmaps, just about this small problem. Suppose I want to have an
enumeration that describes various states that a slot can have besides
having contents.
enum SpecStates { EMPTY = 0, DELETED = -1 };
However, the array that holds the information is an array of 'Record*'s. I
cannot assign EMPTY or DELETED to a slot without an explicit type cast (
(Record*) EMPTY ), since it involves a jump from int to Record*, which is
taken to be from int to void* to Record*. This is ugly and, perhaps,
suboptimal.
I have also considered
const Record* EMPTY = (Record*) 0;
const Record* DELETED = (Record*) 1;
But if I do that I have lost all the convenience of the enumerated type.
What is the correct way to accomplish what I am trying to do, assuming I
want no major design changes (for instance, I want no wrapper for the
Record, since, although that would work, it does not preserve the simplicity
I am seeking)?
James
implementation of an open addressed hashmap. It is homework, but I only
want help on this specific issue. Please do not tell me anything about
hashmaps, just about this small problem. Suppose I want to have an
enumeration that describes various states that a slot can have besides
having contents.
enum SpecStates { EMPTY = 0, DELETED = -1 };
However, the array that holds the information is an array of 'Record*'s. I
cannot assign EMPTY or DELETED to a slot without an explicit type cast (
(Record*) EMPTY ), since it involves a jump from int to Record*, which is
taken to be from int to void* to Record*. This is ugly and, perhaps,
suboptimal.
I have also considered
const Record* EMPTY = (Record*) 0;
const Record* DELETED = (Record*) 1;
But if I do that I have lost all the convenience of the enumerated type.
What is the correct way to accomplish what I am trying to do, assuming I
want no major design changes (for instance, I want no wrapper for the
Record, since, although that would work, it does not preserve the simplicity
I am seeking)?
James