コード例 #1
0
ファイル: LinComb.hpp プロジェクト: bwestbury/confluence
	/*
		Adds a term to the end of the linear combination.
		
		If the object being added is "==" to one already in the list, then the coeffs
		are added.
	*/
	void push_back(monomial p)
	{
		bool found = false;
		for (iterator iter = begin(); iter != end(); iter++) {
			// check to see if there is an object "==" to the one being added
			if (p.second == iter->second) {
				// if so, add the coeffs
				iter->first += p.first;
				if (iter->first == FZERO) {
					// remove the monomial from the linear combination
					contents.erase(iter);
				}
				found = true;
				break;
			}
		}
		// check if the object was "==" to one already in the list
		if (!found) {
			// nope, add it to the end...
			_push_back(p);
		}
	}
コード例 #2
0
ファイル: list_op.cpp プロジェクト: XuWensong/program
void List<I>::push_back(I data)
{
	m_size++;
	Node<I> *n = new Node<I>(data);
	_push_back(n);
}