Revision: 22542
http://sourceforge.net/p/bibdesk/svn/22542
Author: hofman
Date: 2018-08-29 12:08:09 +0000 (Wed, 29 Aug 2018)
Log Message:
-----------
Need to implement hash when implementing isEqual:
Modified Paths:
--------------
trunk/bibdesk/BDSKCondition.m
trunk/bibdesk/BDSKFilter.m
trunk/bibdesk/BDSKMacro.m
trunk/bibdesk/BDSKStringNode.m
Modified: trunk/bibdesk/BDSKCondition.m
===================================================================
--- trunk/bibdesk/BDSKCondition.m 2018-08-29 12:00:00 UTC (rev 22541)
+++ trunk/bibdesk/BDSKCondition.m 2018-08-29 12:08:09 UTC (rev 22542)
@@ -184,6 +184,12 @@
[self comparison] == [(BDSKCondition *)other comparison];
}
+- (NSUInteger)hash {
+ NSUInteger prime = 31;
+ NSUInteger hash = prime * ([[self key] hash] + prime * [[self value]
hash]) + [self comparison];
+ return hash;
+}
+
- (BOOL)isSatisfiedByItem:(BibItem *)item {
if ([NSString isEmptyString:key])
return YES; // empty condition matches anything
Modified: trunk/bibdesk/BDSKFilter.m
===================================================================
--- trunk/bibdesk/BDSKFilter.m 2018-08-29 12:00:00 UTC (rev 22541)
+++ trunk/bibdesk/BDSKFilter.m 2018-08-29 12:08:09 UTC (rev 22542)
@@ -132,6 +132,12 @@
[self conjunction] == [(BDSKFilter *)other conjunction];
}
+- (NSUInteger)hash {
+ NSUInteger prime = 31;
+ NSUInteger hash = [self conjunction] + prime * [[self conditions] hash];
+ return hash;
+}
+
- (NSArray *)filterItems:(NSArray *)items {
NSMutableArray *filteredItems = [NSMutableArray array];
for (id item in items) {
Modified: trunk/bibdesk/BDSKMacro.m
===================================================================
--- trunk/bibdesk/BDSKMacro.m 2018-08-29 12:00:00 UTC (rev 22541)
+++ trunk/bibdesk/BDSKMacro.m 2018-08-29 12:08:09 UTC (rev 22542)
@@ -85,6 +85,10 @@
}
}
+- (NSUInteger)hash {
+ return [[[self name] lowercaseString] hash] + 31 * [[self macroResolver]
hash];
+}
+
- (BOOL)isEqual:(id)other {
if ([other isMemberOfClass:[self class]] == NO)
return NO;
Modified: trunk/bibdesk/BDSKStringNode.m
===================================================================
--- trunk/bibdesk/BDSKStringNode.m 2018-08-29 12:00:00 UTC (rev 22541)
+++ trunk/bibdesk/BDSKStringNode.m 2018-08-29 12:08:09 UTC (rev 22542)
@@ -123,6 +123,10 @@
return (type == [other type] && [value isEqualToString:[other value]]);
}
+- (NSUInteger)hash {
+ return [self type] + 31 * [[self value] hash];
+}
+
- (NSComparisonResult)compareNode:(BDSKStringNode *)aNode{
return [self compareNode:aNode options:0];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit