mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:40:47 +00:00
finish implementng hash methods for NSColor subclasses
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28811 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
36de572f15
commit
13a0f17839
1 changed files with 45 additions and 0 deletions
|
@ -2361,6 +2361,27 @@ static NSRecursiveLock *namedColorLock = nil;
|
||||||
*alpha = _alpha_component;
|
*alpha = _alpha_component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSUInteger) hash
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
uint8_t bytes[sizeof(float)*5];
|
||||||
|
float floats[5];
|
||||||
|
} u;
|
||||||
|
NSUInteger h = 0;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
u.floats[0] = _cyan_component;
|
||||||
|
u.floats[1] = _magenta_component;
|
||||||
|
u.floats[2] = _yellow_component;
|
||||||
|
u.floats[3] = _black_component;
|
||||||
|
u.floats[4] = _alpha_component;
|
||||||
|
for (i = 0; i < sizeof(u); i++)
|
||||||
|
{
|
||||||
|
h = (h << 5) + h + u.bytes[i];
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) isEqual: (id)other
|
- (BOOL) isEqual: (id)other
|
||||||
{
|
{
|
||||||
if (other == self)
|
if (other == self)
|
||||||
|
@ -2600,6 +2621,25 @@ static NSRecursiveLock *namedColorLock = nil;
|
||||||
*alpha = _alpha_component;
|
*alpha = _alpha_component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSUInteger) hash
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
uint8_t bytes[sizeof(float)*3];
|
||||||
|
float floats[3];
|
||||||
|
} u;
|
||||||
|
NSUInteger h = 0;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
u.floats[0] = _red_component;
|
||||||
|
u.floats[1] = _green_component;
|
||||||
|
u.floats[2] = _blue_component;
|
||||||
|
for (i = 0; i < sizeof(u); i++)
|
||||||
|
{
|
||||||
|
h = (h << 5) + h + u.bytes[i];
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) isEqual: (id)other
|
- (BOOL) isEqual: (id)other
|
||||||
{
|
{
|
||||||
if (other == self)
|
if (other == self)
|
||||||
|
@ -3104,6 +3144,11 @@ static NSRecursiveLock *namedColorLock = nil;
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSUInteger) hash
|
||||||
|
{
|
||||||
|
return [_pattern hash];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) isEqual: (id)other
|
- (BOOL) isEqual: (id)other
|
||||||
{
|
{
|
||||||
if (other == self)
|
if (other == self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue