TEST(VectorMapTest, RemoveTest) { Vec v; ASSERT_TRUE(v.empty()); ASSERT_EQ(0, v.size()); ASSERT_FALSE(v.remove(10)); v.insert(10, 1); ASSERT_TRUE(v.end() != v.find(10)); Pair const& p = *(v.find(10)); ASSERT_EQ(1, p.second); ASSERT_TRUE(v.have(10)); ASSERT_TRUE(v.remove(10)); ASSERT_FALSE(v.have(10)); ASSERT_FALSE(v.remove(10)); }
Vec<BoolOpSeq::Item> BoolOpSeq::common_terms() const { if ( not or_seq.size() ) return Vec<BoolOpSeq::Item>(); Vec<BoolOpSeq::Item> res = or_seq[ 0 ]; for( int i = 1; i < or_seq.size(); ++i ) for( int j = 0; j < res.size(); ++j ) if ( not or_seq[ i ].contains( res[ j ] ) ) res.remove( j-- ); return res; }
bool BoolOpSeq::simplify_and_seq( Vec<Item> &and_seq ) { for( int i = 0; i < and_seq.size(); ++i ) { for( int j = i + 1; j < and_seq.size(); ++j ) { if ( and_seq[ i ].expr == and_seq[ j ].expr ) { if ( and_seq[ i ].pos != and_seq[ j ].pos ) return true; // c and not c // c and ... and c and_seq.remove( j-- ); } } } std::sort( and_seq.begin(), and_seq.end(), SortByExpr() ); return false; }
TEST(VectorMapTest, EraseTest) { Vec v; ASSERT_TRUE(v.empty()); ASSERT_EQ(0, v.size()); ASSERT_FALSE(v.remove(10)); v.insert(10, 1); v.insert(11, 2); ASSERT_TRUE(v.end() != v.find(10)); { Pair const& p = *(v.find(10)); ASSERT_EQ(1, p.second); } { Pair const& p = *(v.erase( v.find(10) )); ASSERT_EQ(2, p.second); } }