OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_ORDINAL_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_ORDINAL_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_BASE_ORDINAL_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_ORDINAL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 17 matching lines...) Expand all Loading... |
28 // This means that when Ordinal<T> is used for sorting a list, if any | 28 // This means that when Ordinal<T> is used for sorting a list, if any |
29 // item changes its position in the list, only its Ordinal<T> value | 29 // item changes its position in the list, only its Ordinal<T> value |
30 // has to change to represent the new order, and all the other values | 30 // has to change to represent the new order, and all the other values |
31 // can stay the same. | 31 // can stay the same. |
32 // | 32 // |
33 // An Ordinal<T> is internally represented as an array of bytes, so it | 33 // An Ordinal<T> is internally represented as an array of bytes, so it |
34 // can be serialized to and deserialized from disk. | 34 // can be serialized to and deserialized from disk. |
35 // | 35 // |
36 // The Traits class should look like the following: | 36 // The Traits class should look like the following: |
37 // | 37 // |
38 // // Don't forget to #include "base/basictypes.h". | 38 // // Don't forget to #include <stdint.h> and <stddef.h>. |
39 // struct MyOrdinalTraits { | 39 // struct MyOrdinalTraits { |
40 // // There must be at least two distinct values greater than kZeroDigit | 40 // // There must be at least two distinct values greater than kZeroDigit |
41 // // and less than kMaxDigit. | 41 // // and less than kMaxDigit. |
42 // static const uint8_t kZeroDigit = '0'; | 42 // static const uint8_t kZeroDigit = '0'; |
43 // static const uint8_t kMaxDigit = '9'; | 43 // static const uint8_t kMaxDigit = '9'; |
44 // // kMinLength must be positive. | 44 // // kMinLength must be positive. |
45 // static const size_t kMinLength = 1; | 45 // static const size_t kMinLength = 1; |
46 // }; | 46 // }; |
47 // | 47 // |
48 // An Ordinal<T> is valid iff its corresponding string has at least | 48 // An Ordinal<T> is valid iff its corresponding string has at least |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 DCHECK_LT(midpoint, end_bytes); | 480 DCHECK_LT(midpoint, end_bytes); |
481 | 481 |
482 Ordinal<Traits> midpoint_ordinal(midpoint); | 482 Ordinal<Traits> midpoint_ordinal(midpoint); |
483 DCHECK(midpoint_ordinal.IsValid()); | 483 DCHECK(midpoint_ordinal.IsValid()); |
484 return midpoint_ordinal; | 484 return midpoint_ordinal; |
485 } | 485 } |
486 | 486 |
487 } // namespace syncer | 487 } // namespace syncer |
488 | 488 |
489 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_ORDINAL_H_ | 489 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_ORDINAL_H_ |
OLD | NEW |