//! This module holds all the different string data structures and algorithms described in chapter 5 of the book.

mod searching;
mod sorting;
pub use searching::*;
pub use sorting::Sorting;

const ASCII_SIZE: usize = 256;

#[cfg(test)]
const RANDOM_STRINGS_FOR_TESTING: [&'static str; 100] = [
    "hero",
    "trace",
    "adviser",
    "gas",
    "withdrawal",
    "humanity",
    "stream",
    "grand",
    "illness",
    "disappoint",
    "important",
    "suffering",
    "exemption",
    "disgrace",
    "flawed",
    "skate",
    "soak",
    "twin",
    "complex",
    "shower",
    "cry",
    "proud",
    "senior",
    "salesperson",
    "mistreat",
    "resolution",
    "enemy",
    "equip",
    "day",
    "gene",
    "maximum",
    "scholar",
    "proclaim",
    "salmon",
    "access",
    "penny",
    "allowance",
    "minor",
    "lie",
    "sale",
    "pottery",
    "haunt",
    "rabbit",
    "tape",
    "broken",
    "impulse",
    "slippery",
    "bloody",
    "give",
    "great",
    "perception",
    "swop",
    "major",
    "valid",
    "hole",
    "poor",
    "spirit",
    "conceive",
    "write",
    "citizen",
    "competition",
    "degree",
    "gradient",
    "suffer",
    "distortion",
    "stun",
    "separation",
    "shoot",
    "realize",
    "my",
    "index",
    "tribute",
    "boat",
    "spring",
    "depend",
    "discriminate",
    "acceptable",
    "run",
    "cathedral",
    "splurge",
    "X-ray",
    "hiccup",
    "salvation",
    "cage",
    "motivation",
    "hunter",
    "loan",
    "rest",
    "style",
    "miscarriage",
    "strip",
    "constellation",
    "awful",
    "cooperate",
    "fever",
    "retire",
    "refuse",
    "suburb",
    "record",
    "strain",
];

fn char_at(s: &str, d: usize) -> i16 {
    if d >= s.len() {
        -1
    } else {
        s.as_bytes()[d] as i16
    }
}
