void ExchDoc::AddWord(int sentence, int word) { // Check for valid input if (sentence < 0) throw InvalidIndex(sentence); if (word < 0) throw InvalidIndex(word); if (counts_.find(word) == counts_.end()) { ++num_types_; } ++counts_[word]; ++num_tokens_; }
void *CFreeVariableMap::GetFreeVariableDisallowNULL( const char *pName ) const { int nIndex = Find( pName ); if ( nIndex == InvalidIndex() ) { Log_Warning( LOG_TilegenLayoutSystem, "Free variable '%s' not found.\n", pName ); void *pLayoutSystem = GetFreeVariableOrNULL( "LayoutSystem" ); if ( pLayoutSystem != NULL ) { ( ( CLayoutSystem * ) pLayoutSystem )->OnError(); } return NULL; } void *pPtr = Element( nIndex ); if ( pPtr == NULL ) { Log_Warning( LOG_TilegenLayoutSystem, "Free variable '%s' found, but value is NULL or 0.\n", pName ); void *pLayoutSystem = GetFreeVariableOrNULL( "LayoutSystem" ); if ( pLayoutSystem != NULL ) { ( ( CLayoutSystem * ) pLayoutSystem )->OnError(); } } return pPtr; }
bool Creature::empty() const { Monitor msg; if (!check_creator(msg)) return true; if (id == InvalidIndex()) return true; return false; }
bool Creature::ok() const { Monitor msg; if (!check_creator(msg)) return false; if (id == InvalidIndex()) return false; return creator->check_creature(id,msg); }
void clear() { aclass = atcInvalid; dtype = derInvalid; btype = berInvalid; stype = astInvalid; no.set(InvalidIndex()); }
void *CFreeVariableMap::GetFreeVariableOrNULL( const char *pName ) const { int nIndex = Find( pName ); if ( nIndex == InvalidIndex() ) { return NULL; } return Element( nIndex ); }
const T& SymMatrix<T>::operator()(unsigned long row, unsigned long col) const { if(row >= Matrix<T>::numRows()) throw InvalidIndex(row); if(col < row) return Matrix<T>::data[col][row]; else return Matrix<T>::data[row][col]; }
T& SymMatrix<T>::at(unsigned long row, unsigned long col) { if(row >= Matrix<T>::numRows()) throw InvalidIndex(row); if(col < row) return Matrix<T>::data[col].at(row); else return Matrix<T>::data[row].at(col); }
Vector<T> LowerTriangular<T>::getCol(unsigned long i) const { if(i >= Matrix<T>::m_cols) throw InvalidIndex(i); Vector<T> retval(Matrix<T>::m_cols, i, 0); for(unsigned long j = i; j < Matrix<T>::m_cols; j++) retval.at(j) = Matrix<T>::operator()(j, i); return retval; }
CASW_DamageAllocationMgr::IndexType_t CASW_DamageAllocationMgr::Find( const EHANDLE &handle ) { for ( int i = m_Targets.Count() - 1; i >= 0 ; --i ) { if ( m_Targets[i].m_hTargeted == handle ) return (&m_Targets[i]); } // didn't find return InvalidIndex(); }
void CFreeVariableMap::SetOrCreateFreeVariable( const char *pName, void *pValue ) { int nIndex = Find( pName ); if ( nIndex != InvalidIndex() ) { Element( nIndex ) = pValue; } else { Insert( pName, pValue ); } }
/** * * Kupacban elemet feljebbmozgató eljárás * * @param index az elem indexe, amit feljebb kell mozgatni * */ void liftUp(std::size_t index) { if (index >= v.size()) { throw InvalidIndex(); } std::size_t parent = getParent(index); while(index != 0 && v[parent] < v[index]) { std::swap(v[parent], v[index]); index = parent; parent = getParent(index); } }
void initializeCircularSpreading(std::vector<double> &pars) { if (pars.empty()) { pars.push_back(0.5); } else if (pars.size()==1) { if (pars[0]<=-1 || pars[0]>=1) throw NotElement(std::string("Error in ") + "\"initializeCircularSpreading\":\n " + "The deforming parameter of the circular map must be in (-1, 1)"); } else { throw InvalidIndex(std::string("Error in ") + "\"initializeCircularSpreading\":\n " + "The circular map has only one parameter"); } }
void initializeFs2blSpreading(std::vector<double> &pars) { if (pars.empty()) { pars.push_back(0); pars.push_back(0.5); pars.push_back(1); } else if (pars.size()==3) { if (!boost::algorithm::is_increasing(pars.begin(), pars.end())) throw InvalidOrder(std::string("Error in ") + "\"initializeFs2blSpreading\":\n " + "The parameters of the map must be strictly ordered as in\n " + "domain lower bound < non-centrality < domain upper bound."); } else { throw InvalidIndex(std::string("Error in ") + "\"initializeFs2blSpreading\":\n " + "Either specify all three parameters of the map or none."); } }
/** * * Kupacban elemet lejjebbmozgató eljárás * * @param index az elem indexe, amit lejjebb kell mozgatni * */ void liftDown(std::size_t index) { if (index >= v.size()) { throw InvalidIndex(); } size_t left_child = leftChild(index), right_child = rightChild(index); while ((right_child < v.size() && v[index] < v[right_child]) || (left_child < v.size() && v[index] < v[left_child] )) { if (right_child < v.size() && v[left_child] < v[right_child]) { std::swap(v[right_child], v[index]); index = right_child; } else { std::swap(v[left_child], v[index]); index = left_child; } left_child = leftChild(index); right_child = rightChild(index); } }
HasherReal(CreatorInt& creat, AlgorithmId alg, AlgorithmPreference pref, Index provider_pref = InvalidIndex()) : CreatureDefaultImplementation<eprovider::Hasher>(creat, alg, pref, provider_pref), stopped_state(false) {}
Iterator ParametersReal::iterator() { //TODO: throw std::runtime_error("Not Implemented"); return Iterator(InvalidIndex(),InvalidIndex()); }