//-------------------------------------------------------------------------- // File and Version Information: // $Id: AstFracElem.cc,v 1.1.1.1 2005/03/29 16:49:05 steinke Exp $ // // Description: // Class AstFracElem // // Environment: // Software developed for the BaBar Detector at the SLAC B-Factory. // // Author List: // David Brown // // Copyright Information: // Copyright (C) 2000 Lawrence Berkeley Laboratory // // Bertram Kopf (RUB) migrated to PandaRoot //------------------------------------------------------------------------ #include "AstFracElem.h" template AstFracElem::AstFracElem(const B* bterm, double weight) : _weight(weight), _elem(bterm) {;} template AstFracElem::AstFracElem() : _weight(0.0), _elem(0) {;} template AstFracElem::AstFracElem(const AstFracElem& other) : _weight(other._weight), _elem(other._elem) {;} template AstFracElem& AstFracElem::operator = (const AstFracElem& other) { if(this != &other){ _elem = other._elem; _weight = other._weight; } return *this; } template AstFracElem::~AstFracElem() {;} template bool AstFracElem::sameElement(const AstFracElem& other) const { return _elem == other._elem || _elem==0 || other._elem==0; } template bool AstFracElem::ltElement(const AstFracElem& other) const { return _elem !=0 && other._elem != 0 && _elem < other._elem; } template bool AstFracElem::gtElement(const AstFracElem& other) const { return _elem !=0 && other._elem != 0 && _elem > other._elem; } // arithmetic allowed only if logically equal template AstFracElem& AstFracElem::operator += (const AstFracElem& other) { if(_elem == other._elem)_weight += other.weight(); return *this; } template AstFracElem& AstFracElem::operator -= (const AstFracElem& other) { if(_elem == other._elem)_weight -= other.weight(); return *this; } // compare by weights. The perversity of RW sorted vector requires // I reverse the meaning of < and > in order to get a list with the // largest value first. template bool AstFracElem::operator < (const AstFracElem& other) const { return _weight > other._weight; } template bool AstFracElem::operator > (const AstFracElem& other) const { return weight < other._weight; } template bool AstFracElem::operator == (const AstFracElem& other) const { return _weight == other._weight; } template bool AstFracElem::operator != (const AstFracElem& other) const { return !( *this == other); }