2019-12-19 17:32:49 +00:00
|
|
|
/*
|
2023-04-06 09:44:16 +00:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2016-09-07 22:37:59 +00:00
|
|
|
*
|
2018-05-01 21:33:50 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-09-07 22:37:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#import "IGListMoveIndex.h"
|
|
|
|
|
|
|
|
|
|
@implementation IGListMoveIndex
|
|
|
|
|
|
2016-11-16 23:15:55 +00:00
|
|
|
- (instancetype)initWithFrom:(NSInteger)from to:(NSInteger)to {
|
2016-09-07 22:37:59 +00:00
|
|
|
if (self = [super init]) {
|
|
|
|
|
_from = from;
|
|
|
|
|
_to = to;
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSUInteger)hash {
|
|
|
|
|
return _from ^ _to;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)isEqual:(id)object {
|
|
|
|
|
if (object == self) {
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
if ([object isKindOfClass:[IGListMoveIndex class]]) {
|
2016-11-16 23:15:55 +00:00
|
|
|
const NSInteger f1 = self.from, f2 = [object from];
|
|
|
|
|
const NSInteger t1 = self.to, t2 = [object to];
|
2016-09-07 22:37:59 +00:00
|
|
|
return f1 == f2 && t1 == t2;
|
|
|
|
|
}
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSComparisonResult)compare:(id)object {
|
2016-11-16 23:15:55 +00:00
|
|
|
const NSInteger right = [object from];
|
|
|
|
|
const NSInteger left = [self from];
|
2016-09-07 22:37:59 +00:00
|
|
|
if (left == right) {
|
|
|
|
|
return NSOrderedSame;
|
|
|
|
|
} else if (left < right) {
|
|
|
|
|
return NSOrderedAscending;
|
|
|
|
|
} else {
|
|
|
|
|
return NSOrderedDescending;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)description {
|
Minimum fixes for Xcode 9.3 build errors
Summary:
Issue fixed: #1141
This is a set of minimum fixes for Xcode 9.3 rather than #1142. Much smaller diffs 😃
The changes here were done by Xcode's FixIt. See also https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265-SW5.
> Platform Dependencies
>
> OS X uses several data types—NSInteger, NSUInteger,CGFloat, and CFIndex—to provide a consistent means of representing values in 32- and 64-bit environments. In a 32-bit environment, NSInteger and NSUInteger are defined as int and unsigned int, respectively. In 64-bit environments, NSInteger and NSUInteger are defined as long and unsigned long, respectively. To avoid the need to use different printf-style type specifiers depending on the platform, you can use the specifiers shown in Table 3. Note that in some cases you may have to cast the value.
- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes https://github.com/Instagram/IGListKit/pull/1143
Differential Revision: D7551617
Pulled By: rnystrom
fbshipit-source-id: b27ebe2b1a1c93ebfd1218dc38b7621fefee2e6b
2018-04-09 15:06:47 +00:00
|
|
|
return [NSString stringWithFormat:@"<%@ %p; from: %li; to: %li;>", NSStringFromClass(self.class), self, (long)self.from, (long)self.to];
|
2016-09-07 22:37:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|