#include <Integer.h>
Inheritance diagram for Core::Integer:
Public Member Functions | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual double | asDouble (void) const |
virtual long long | asLongLong (void) const |
virtual long | hash (void) const |
Answer object hash value. | |
virtual bool | isEqual (const Object *object) const |
Compare receiver with given object. | |
virtual bool | isEqual (const Object &object) const |
Compare receiver with given object. | |
virtual bool | isEqual (int arg) const |
virtual bool | isEqual (double arg) const |
virtual bool | isEqualToDouble (double arg) const |
virtual bool | isEqualToLongLong (long long arg) const |
virtual Number * | negate (void) |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
virtual bool | isInteger (void) const |
virtual bool | isPositive (void) const |
Answer whether the recevier is positive (including zero). | |
virtual bool | isZero (void) const |
Answer whether the receiver represents a zero in it's domain. | |
Static Public Member Functions | |
static Integer * | value (long long val) |
Protected Member Functions | |
Integer (long long val) | |
Protected Attributes | |
long long | _value |
Static Protected Attributes | |
static Array | _instances |
native integers (long long int) that are of limited size. Generally a long
wrapper for operations with other numbers. First 512 integers (0 to 511) are cached to avoid frequent instance creation. All methods are commented in the Number
class.
Definition at line 45 of file Integer.h.
|
Definition at line 37 of file Integer.cc. References _value. Referenced by value(). 00038 { 00039 _value = val; 00040 }
|
|
Reimplemented from Core::Number. Definition at line 63 of file Integer.cc. References _value. 00064 { 00065 return (double) _value; 00066 }
|
|
Reimplemented from Core::Number. Definition at line 68 of file Integer.cc. References _value. 00069 { 00070 return _value; 00071 }
|
|
Answer receiver class name. Because there isn't any standard way to obtain class name this method comes to place. Every class should rewrite this method but many didn't (yet). Reimplemented from Core::Number. Definition at line 43 of file Integer.cc. 00044 { 00045 return new String("Integer"); 00046 }
|
|
Answer object hash value. The value should be same for objects found equal with isEqual() method. So if you rewrite this method you should rewrite isEqual() method too. Reimplemented from Core::Object. Definition at line 74 of file Integer.cc. References _value. 00075 { 00076 return (long) _value; 00077 }
|
|
Reimplemented from Core::Number. Definition at line 72 of file Integer.h. References Core::Number::isEqual(). 00073 { return Number::isEqual(arg); }
|
|
Reimplemented from Core::Number. Definition at line 70 of file Integer.h. References Core::Number::isEqual(). 00071 { return Number::isEqual(arg); }
|
|
Compare receiver with given object. Do not rewrite this method. It just a sugar for Object::isEqual(Object *).
Reimplemented from Core::Number. Definition at line 68 of file Integer.h. References Core::Number::isEqual(). 00069 { return Number::isEqual(object); }
|
|
Compare receiver with given object. This method could compare objects with more sophisticated algorithm (eg. based on instance variables comparing or so). If you rewrite this method you should rewrite hash() too.
Reimplemented from Core::Number. Definition at line 79 of file Integer.cc. References _value. 00080 { 00081 if (!object->isNumber()) return false; 00082 00083 return ((Number *) object)->isEqualToLongLong(_value); 00084 }
|
|
Reimplemented from Core::Number. Definition at line 92 of file Integer.cc. References _value. 00093 { 00094 return _value == arg; 00095 }
|
|
Reimplemented from Core::Number. Definition at line 87 of file Integer.cc. References _value. 00088 { 00089 return _value == arg; 00090 }
|
|
Reimplemented from Core::Number. Definition at line 113 of file Integer.cc. 00114 { 00115 return true; 00116 }
|
|
Answer whether the recevier is positive (including zero).
Reimplemented from Core::Number. Definition at line 118 of file Integer.cc. References _value. 00119 { 00120 return _value >= 0; 00121 }
|
|
Answer whether the receiver represents a zero in it's domain.
Reimplemented from Core::Number. Definition at line 123 of file Integer.cc. References _value. Referenced by negate(). 00124 { 00125 return _value == 0; 00126 }
|
|
Reimplemented from Core::Number. Definition at line 98 of file Integer.cc. References _value, isZero(), and value(). 00099 { 00100 if (isZero()) return this; 00101 return Integer::value(-_value); 00102 }
|
|
Print object identification into the stream. Object identification is formed from its className() by default. But complicated classes (eg. collections) may print some other information.
Reimplemented from Core::Object. Definition at line 105 of file Integer.cc. References _value, and Core::Stream::nextPutAll(). 00106 { 00107 char number[25]; 00108 sprintf(number, "%lld", _value); 00109 stream->nextPutAll(number); 00110 }
|
|
|
Referenced by value(). |
|
Definition at line 48 of file Integer.h. Referenced by asDouble(), asLongLong(), hash(), Integer(), isEqual(), isEqualToDouble(), isEqualToLongLong(), isPositive(), isZero(), negate(), and printOn(). |