OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. |
| 2 // |
| 3 // Permission is hereby granted, free of charge, to any person |
| 4 // obtaining a copy of this software and associated documentation |
| 5 // files (the "Software"), to deal in the Software without |
| 6 // restriction, including without limitation the rights to use, |
| 7 // copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 // copies of the Software, and to permit persons to whom the |
| 9 // Software is furnished to do so, subject to the following |
| 10 // conditions: |
| 11 // |
| 12 // The above copyright notice and this permission notice shall be |
| 13 // included in all copies or substantial portions of the Software. |
| 14 // |
| 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 17 // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 19 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 20 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 // OTHER DEALINGS IN THE SOFTWARE. |
| 23 // |
| 24 // ChangeLog: |
| 25 // 2016-07-22 - Initial commit and adaption to use PagedArray. |
| 26 // --Samuel Huang <huangs@chromium.org> |
| 27 |
| 28 #ifndef COURGETTE_BSDIFF_THIRD_PARTY_DIVSUFSORT_H_ |
| 29 #define COURGETTE_BSDIFF_THIRD_PARTY_DIVSUFSORT_H_ |
| 30 |
| 31 #include <stdint.h> |
| 32 |
| 33 #include "courgette/third_party/bsdiff/paged_array.h" |
| 34 |
| 35 namespace divsuf { |
| 36 |
| 37 /*- Datatypes -*/ |
| 38 typedef int32_t saint_t; |
| 39 typedef int32_t saidx_t; |
| 40 typedef uint8_t sauchar_t; |
| 41 |
| 42 #ifdef DIVSUFSORT_NO_PAGED_ARRAY |
| 43 typedef saidx_t* saidx_it; |
| 44 typedef const saidx_t* const_saidx_it; |
| 45 #else |
| 46 typedef courgette::PagedArray<saidx_t>::iterator saidx_it; |
| 47 typedef courgette::PagedArray<saidx_t>::const_iterator const_saidx_it; |
| 48 #endif |
| 49 |
| 50 /*- Prototypes -*/ |
| 51 |
| 52 /** |
| 53 * Constructs the suffix array of a given string, excluding the empty string. |
| 54 * @param T[0..n-1] The input string. |
| 55 * @param SA[0..n-1] The output array of suffixes. |
| 56 * @param n The length of the given string. |
| 57 * @return 0 if no error occurred, -1 or -2 otherwise. |
| 58 */ |
| 59 saint_t divsufsort(const sauchar_t *T, saidx_it SA, saidx_t n); |
| 60 |
| 61 /** |
| 62 * Constructs the suffix array of a given string, including the empty string. |
| 63 * @param T[0..n-1] The input string. |
| 64 * @param SA[0..n] The output array of suffixes (includes empty string). |
| 65 * @param n The length of the given string. |
| 66 * @return 0 if no error occurred, -1 or -2 otherwise. |
| 67 */ |
| 68 saint_t divsufsort_include_empty(const sauchar_t *T, saidx_it SA, saidx_t n); |
| 69 |
| 70 } // namespace divsuf |
| 71 |
| 72 #endif // COURGETTE_BSDIFF_THIRD_PARTY_DIVSUFSORT_H_ |
OLD | NEW |