void save_table( const std::string& filename, const table_type& table) { APP_DEBUG_FNAME; DEBUG("save: %s", filename); using std::endl; std::ofstream out(filename); size_t m, n; m = table.size(); n = table.at(0).size(); out << m << " " << n << endl; for (size_t i = 0; i < m; ++i) { for (size_t j = 0; j < n; ++j) { const table_value_type& val = table[i][j]; out << file_value_type(val) << " "; } out << endl; } if (out.fail()) throw io_exception("save_table(%s) failed", filename); }
void resize(size_type size) { if (size > table_.size()) { reserve(size); } else { table_.resize(size); } }
void reserve(size_type size) { for (size_type i = table_.size(); i < size; ++i) { table_.push_back( prefix_ + sprig::str_cast<string_type>(i) ); } }
inline int searchsorted(const table_type& z_table, const double value) { int i(0); for (table_type::const_iterator itr(z_table.begin()); itr != z_table.end(); ++itr) { if (value <= *itr) return i; ++i; } return i; }
static void remove(const jas& j) { iterator_type iter = s_this_to_sn_.find(&j); BOOST_CHECK(iter != s_this_to_sn_.end()); BOOST_CHECK( ((*iter).second) == j.sn_); int sn = (*iter).second; if(sn != j.sn_) { cout << "Mismatch: this = " << (*iter).first << ", sn_ = " << sn << ", other: this = " << &j << ", j.sn_ = " << j.sn_ << endl; } BOOST_CHECK(sn == j.sn_); s_this_to_sn_.erase(&j); cout << "jas( " << j.sn_ << ") Removed" << endl; }
symbol_type operator()(const symbol_type& symbol) const { const std::string& word = static_cast<const std::string&>(symbol); icu::UnicodeString uword = icu::UnicodeString::fromUTF8(icu::StringPiece(word.data(), word.size())); Unicode& impl = const_cast<Unicode&>(*this); bool dg = false; uint32_t gc = 0; uscript_type sc(script_.size(), false); icu::StringCharacterIterator iter(uword); for (iter.setToStart(); iter.hasNext(); /**/) { const UChar32 ch = iter.next32PostInc(); dg |= (u_getNumericValue(ch) != U_NO_NUMERIC_VALUE); gc |= u_getIntPropertyValue(ch, UCHAR_GENERAL_CATEGORY_MASK); sc[u_getIntPropertyValue(ch, UCHAR_SCRIPT)] = true; } std::string signature = "<unk"; for (int i = 1; i < U_CHAR_CATEGORY_COUNT; ++ i) if (gc & U_MASK(i)) { signature += "-"; signature += general_category_[i]; } for (int i = 1; i < USCRIPT_CODE_LIMIT; ++ i) if (sc[i]) { signature += "-"; signature += script_[i]; } if (dg) signature += "-NUM"; signature += '>'; return signature; }
static void check() { BOOST_CHECK(s_this_to_sn_.empty()); }
string_type const& operator[](size_type i) const { return table_.at(i); }