Some of the Object::equals now are const correct.
There's more to do. Why make this const-correct, instead of ditch it? Because whatever I replace it with has to be ready for const correctness.
This commit is contained in:
@ -48,7 +48,8 @@ Object::~Object()
|
||||
* this makes casting of "other" safe. Typically, an implementation should
|
||||
* check this == other first, the caller can assume a fast implementation.
|
||||
*/
|
||||
bool Object::equals(Object *other)
|
||||
bool
|
||||
Object::equals( const Object *const other ) const
|
||||
{
|
||||
misc::assertNotReached ();
|
||||
return false;
|
||||
@ -149,7 +150,7 @@ StandardComparator standardComparator;
|
||||
// Pointer
|
||||
// -------------
|
||||
|
||||
bool Pointer::equals(Object *other)
|
||||
bool Pointer::equals(const Object *other) const
|
||||
{
|
||||
return value == ((Pointer*)other)->value;
|
||||
}
|
||||
@ -187,7 +188,7 @@ void Pointer::intoStringBuffer(misc::StringBuffer *sb)
|
||||
// Integer
|
||||
// -------------
|
||||
|
||||
bool Integer::equals(Object *other)
|
||||
bool Integer::equals(const Object *other) const
|
||||
{
|
||||
return value == ((Integer*)other)->value;
|
||||
}
|
||||
@ -213,7 +214,7 @@ int Integer::compareTo(Comparable *other)
|
||||
// Boolean
|
||||
// -------------
|
||||
|
||||
bool Boolean::equals(Object *other)
|
||||
bool Boolean::equals(const Object *other) const
|
||||
{
|
||||
bool value2 = ((Boolean*)other)->value;
|
||||
// TODO Does "==" work?
|
||||
@ -239,7 +240,7 @@ int Boolean::compareTo(Comparable *other)
|
||||
// ConstString
|
||||
// -----------------
|
||||
|
||||
bool ConstString::equals(Object *other)
|
||||
bool ConstString::equals(const Object *other) const
|
||||
{
|
||||
ConstString *otherString = (ConstString*)other;
|
||||
return
|
||||
@ -317,7 +318,7 @@ PairBase::~PairBase()
|
||||
delete second;
|
||||
}
|
||||
|
||||
bool PairBase::equals(Object *other)
|
||||
bool PairBase::equals(const Object *other) const
|
||||
{
|
||||
PairBase *otherPair = (PairBase*)other;
|
||||
|
||||
@ -347,7 +348,7 @@ int PairBase::hashValue()
|
||||
return value;
|
||||
}
|
||||
|
||||
void PairBase::intoStringBuffer(misc::StringBuffer *sb)
|
||||
void PairBase::intoStringBuffer(misc::StringBuffer *sb) const
|
||||
{
|
||||
sb->append("<pair: ");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user