Exemplo n.º 1
0
std::size_t infix_configuration_hasher::hash(const infix_configuration& v) {
    std::size_t seed(0);

    combine(seed, v.first());
    combine(seed, v.not_first());
    combine(seed, v.not_last());
    combine(seed, v.last());

    return seed;
}
Exemplo n.º 2
0
std::string sequence_formatter::
value_for_position(const infix_configuration& ic) const {
    if (is_single()) {
        if (!ic.first().empty()) {
            // when we are single, first takes priority if supplied.
            return ic.first();
        }
        return ic.last();
    } else if (is_first() && !ic.first().empty()) {
        // if is first and first has been supplied, it takes precedence.
        return ic.first();
    } else if (!is_last() && !ic.not_last().empty()) {
        // if we are not last (including first) and not last has been
        // supplied.
        return ic.not_last();
    } else if (!is_first() && (!is_last() || !ic.not_first().empty())) {
        // when we are last, not first takes precedence if supplied.
        return ic.not_first();
    } else if (is_last())
        return ic.last();

    return empty;
}