1 /* 2 * CSet.cc 3 * 4 * Copyright 2014-2018 D. Mitch Bailey cvc at shuharisystem dot com 5 * 6 * This file is part of cvc. 7 * 8 * cvc is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * cvc is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with cvc. If not, see <http://www.gnu.org/licenses/>. 20 * 21 * You can download cvc from https://github.com/d-m-bailey/cvc.git 22 */ 23 24 #include "CSet.hh" 25 Intersects(CSet & theOtherSet)26bool CSet::Intersects(CSet & theOtherSet) { 27 CSet *mySmallSet_p, *myLargeSet_p; 28 if ( size() > theOtherSet.size() ) { 29 mySmallSet_p = &theOtherSet; 30 myLargeSet_p = this; 31 } else { 32 mySmallSet_p = this; 33 myLargeSet_p = &theOtherSet; 34 } 35 for ( auto myItem = mySmallSet_p->begin(); myItem != mySmallSet_p->end(); myItem++ ) { 36 if ( myLargeSet_p->count(*myItem) > 0 ) return true; 37 } 38 return false; 39 }; 40 41 42 43