Beispiel #1
0
int32_t
divsufsort(const uint8_t *T, int32_t *SA, int32_t n) {
  int32_t m;
  int32_t err = 0;

  /* Check arguments. */
  if ((T == NULL) || (SA == NULL) || (n < 0)) {
    return -1;
  } else if (n == 0) {
    return 0;
  } else if (n == 1) {
    SA[0] = 0;
    return 0;
  } else if (n == 2) {
    m = (T[0] < T[1]);
    SA[m ^ 1] = 0, SA[m] = 1;
    return 0;
  }

  int32_t bucket_A [BUCKET_A_SIZE];
  int32_t bucket_B [BUCKET_B_SIZE];

  /* Suffixsort. */
  m = sort_typeBstar(T, SA, bucket_A, bucket_B, n);
  construct_SA(T, SA, bucket_A, bucket_B, n, m);

  return err;
}
Beispiel #2
0
saint_t
divsufsort(const sauchar_t *T, saidx_t *SA, saidx_t n) {
  saidx_t *bucket_A, *bucket_B;
  saidx_t m;
  saint_t err = 0;

  /* Check arguments. */
  if((T == NULL) || (SA == NULL) || (n < 0)) { return -1; }
  else if(n == 0) { return 0; }
  else if(n == 1) { SA[0] = 0; return 0; }
  else if(n == 2) { m = (T[0] < T[1]); SA[m ^ 1] = 0, SA[m] = 1; return 0; }

//  bucket_A = (saidx_t *)malloc(BUCKET_A_SIZE * sizeof(saidx_t));
//  bucket_B = (saidx_t *)malloc(BUCKET_B_SIZE * sizeof(saidx_t));
  bucket_A = bucketA_buffer;
  bucket_B = bucketB_buffer;

  /* Suffixsort. */
  if((bucket_A != NULL) && (bucket_B != NULL)) {
    m = sort_typeBstar(T, SA, bucket_A, bucket_B, n);
    construct_SA(T, SA, bucket_A, bucket_B, n, m);
  } else {
    err = -2;
  }

  //free(bucket_B);
  //free(bucket_A);

  return err;
}