// Perform a exact search for the string w using the backwards algorithm void SBWT::backwardSearch(std::string w) const { std::cout << "Searching for " << w << "\n"; int len = w.size(); int j = len - 1; char curr = w[j]; int r_lower = PRED(curr); int r_upper = r_lower + OCC(curr, m_bwStr.length() - 1) - 1; --j; std::cout << "Starting point: " << r_lower << "," << r_upper << "\n"; for(;j >= 0; --j) { curr = w[j]; printf("RL = C(%c) + O(%c,%d) + %zu\n", curr, curr, r_lower - 1, m_numStrings); printf("RU = C(%c) + O(%c,%d)\n", curr, curr, r_upper); printf("RL = %zu + %zu + %zu\n", (size_t)PRED(curr), (size_t)OCC(curr, r_lower - 1), m_numStrings); printf("RU = %zu + %zu\n", (size_t)PRED(curr), (size_t)OCC(curr, r_upper)); r_lower = PRED(curr) + OCC(curr, r_lower - 1); r_upper = PRED(curr) + OCC(curr, r_upper) - 1; printf("Curr: %c, Interval now: %d,%d\n", curr, r_lower, r_upper); } std::cout << "Interval found: " << r_lower << "," << r_upper << "\n"; }
/*--------------------------------------------------------------------------- * OBEXH_GetAvailableTxHeaderLen() *--------------------------------------------------------------------------- * * Synopsis: Returns the amount of header space available for adding more * headers. This value is constrained by the OBEX Packet size, * the application provided header buffer size and any headers * which are already present in the buffer. * * Return: Available header buffer length in bytes. */ U16 OBEXH_GetAvailableTxHeaderLen(ObexAppHandle *AppHndl) { #if OBEX_SERVER_CONS_SIZE > 0 || OBEX_SESSION_SUPPORT == XA_ENABLED void *ObexApp = AppHndl; #endif /* OBEX_SERVER_CONS_SIZE > 0 || OBEX_SESSION_SUPPORT == XA_ENABLED */ U16 avail; ASSERT(AppHndl); OS_LockObex(); /* Just assume Connect to get a size that will always work. */ avail = ObParserMaxHbSize(&AppHndl->parser, OB_OPCODE_CONNECT); #if (OBEX_SERVER_CONS_SIZE > 0) || (OBEX_SESSION_SUPPORT == XA_ENABLED) if (IsServerParser(&AppHndl->parser)) { #if OBEX_ROLE_SERVER == XA_ENABLED avail -= OSC(protoTxLen); #endif /* OBEX_ROLE_SERVER == XA_ENABLED */ } #if OBEX_SESSION_SUPPORT == XA_ENABLED else { ASSERT(IsClientParser(&AppHndl->parser)); #if OBEX_ROLE_CLIENT == XA_ENABLED avail -= OCC(protoTxLen); #endif /* OBEX_ROLE_CLIENT == XA_ENABLED */ } #endif /* OBEX_SESSION_SUPPORT == XA_ENABLED */ #endif /* (OBEX_SERVER_CONS_SIZE > 0) || (OBEX_SESSION_SUPPORT == XA_ENABLED) */ avail = min(avail, AppHndl->length); avail -= AppHndl->txLength; OS_UnlockObex(); return avail; }
// Compute the last to first mapping size_t SBWT::LF(size_t idx) const { return m_bwStr.get(idx) != '$' ? PRED(m_bwStr.get(idx)) + OCC(m_bwStr.get(idx), idx) : 0; }