FSTComparison.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** Compares two NSStrings. */
  19. NSComparisonResult FSTCompareStrings(NSString *left, NSString *right);
  20. /** Compares two BOOLs. */
  21. NSComparisonResult FSTCompareBools(BOOL left, BOOL right);
  22. /** Compares two integers. */
  23. NSComparisonResult FSTCompareInts(int left, int right);
  24. /** Compares two int32_t. */
  25. NSComparisonResult FSTCompareInt32s(int32_t left, int32_t right);
  26. /** Compares two int64_t. */
  27. NSComparisonResult FSTCompareInt64s(int64_t left, int64_t right);
  28. /** Compares two NSUIntegers. */
  29. NSComparisonResult FSTCompareUIntegers(NSUInteger left, NSUInteger right);
  30. /** Compares two doubles (using Firestore semantics for NaN). */
  31. NSComparisonResult FSTCompareDoubles(double left, double right);
  32. /** Compares a double and an int64_t. */
  33. NSComparisonResult FSTCompareMixed(double doubleValue, int64_t longValue);
  34. /** Compare two NSData byte sequences. */
  35. NSComparisonResult FSTCompareBytes(NSData *left, NSData *right);
  36. /** A simple NSComparator for comparing NSNumber instances. */
  37. extern const NSComparator FSTNumberComparator;
  38. /** A simple NSComparator for comparing NSString instances. */
  39. extern const NSComparator FSTStringComparator;
  40. /**
  41. * Compares the bitwise representation of two doubles, but normalizes NaN values. This is
  42. * similar to what the backend and android clients do, including comparing -0.0 as not equal to 0.0.
  43. */
  44. BOOL FSTDoubleBitwiseEquals(double left, double right);
  45. /**
  46. * Computes a bitwise hash of a double, but normalizes NaN values, suitable for use when using
  47. * FSTDoublesAreBitwiseEqual for equality.
  48. */
  49. NSUInteger FSTDoubleBitwiseHash(double d);
  50. NS_ASSUME_NONNULL_END