Example #1
0
void ColumnFixedString::getExtremes(Field & min, Field & max) const
{
    min = String();
    max = String();

    size_t col_size = size();

    if (col_size == 0)
        return;

    size_t min_idx = 0;
    size_t max_idx = 0;

    less<true> less_op(*this);

    for (size_t i = 1; i < col_size; ++i)
    {
        if (less_op(i, min_idx))
            min_idx = i;
        else if (less_op(max_idx, i))
            max_idx = i;
    }

    get(min_idx, min);
    get(max_idx, max);
}
Example #2
0
void
PinyinPhraseLib::dump_content (std::ostream &os, int minlen, int maxlen)
{
	PinyinPhraseLessThanByOffset less_op (this, m_pinyin_key_less);
	if (minlen < 1) minlen = 1;
	if (maxlen > SCIM_PHRASE_MAX_LENGTH) maxlen = SCIM_PHRASE_MAX_LENGTH;

	for (int i = minlen; i <= maxlen; ++ i) {
		PinyinPhraseOffsetVector offsets;
		for (PinyinPhraseTable::iterator tit = m_phrases [i-1].begin (); tit != m_phrases [i-1].end (); ++ tit) {
			PinyinPhraseOffsetVector::iterator begin = tit->get_vector ().begin ();
			PinyinPhraseOffsetVector::iterator end = tit->get_vector ().end ();
			offsets.insert (offsets.end (), begin, end);
		}

		std::sort (offsets.begin (), offsets.end (), less_op);

		for (PinyinPhraseOffsetVector::iterator oit = offsets.begin (); oit != offsets.end (); ++ oit) {
			bool before = false, after = false;

			os << get_phrase (oit->first).frequency () << "\t";
			if (oit > offsets.begin () && get_phrase ((oit-1)->first) == get_phrase (oit->first)) before = true;
			if (oit < offsets.end () - 1 && get_phrase ((oit+1)->first) == get_phrase (oit->first)) after = true;
			if (before || after) os << "+";
			else os << "-";
			os << utf8_wcstombs (get_phrase (oit->first).get_content ());
			os << " =";
			for (unsigned int j = 0; j < get_phrase (oit->first).length (); ++ j)
				os << " " << get_pinyin_key (oit->second + j);
			os << "\n";
		}
	}
}
bool operator<(const scalar_base& x, const scalar_base& y) {
    if (x.type() != y.type()) return x.type() < y.type();
    if (x.type() == NULL_TYPE) return false;
    return internal::visit<bool>(x, less_op(y));
}