inline vec1<int> partitionToList(const vec1<vec1<int> >& part, int size, MissingPoints mp) { vec1<int> vec(size, 0); int covered = 1; for(int i : range1(part.size())) { for(int val : part[i]) { D_ASSERT(vec[val] == 0); vec[val] = i; covered++; } } // Maybe the permutation is missing some values of the end. These // should all be treated as defined by 'MissingPoints' if(mp == MissingPoints_Fixed) { for(int i : range1(vec.size())) { if(vec[i] == 0) vec[i] = vec.size() + 1 + i; // (is +1 required? It doesn't hurt) } } return vec; }
Graph(const vec1<vec1<VertexType> >& _points_in, int domain) { vec1<vec1<VertexType> > _points = compressGraph(_points_in); if(_points.size() > domain) throw GAPException("Graph too large"); edges = _points; edges.resize(domain); for(int i : range1(_points.size())) { int i_size = _points[i].size(); for(int j = 1; j <= i_size; ++j) { if(_points[i][j].target() <= 0 || _points[i][j].target() > domain) { throw GAPException("Graph contains out-of-bounds vertex: " + toString(_points[i][j].target())); } if(_points[i][j].colour() < 0 ) { throw GAPException(" Graph contains invalid edge colour: " + toString(_points[i][j].colour())); } VertexType edge(i, _points[i][j].colour()); if(directed) { edge = edge.flipped(); } edges[_points[i][j].target()].push_back(edge); } } for(int i : range1(edges.size())) { std::set<VertexType> pntset(edges[i].begin(), edges[i].end()); edges[i] = vec1<VertexType>(pntset.begin(), pntset.end()); } }
TEST(ConsistentHashMapTest, TestGetRange) { TestMap test_map; typedef std::pair<string, Range<size_t>> node_range_type; const string node1("node1"); test_map.insert(0, node1); size_t range = numeric_limits<size_t>::max() / test_map.num_partitions(); vector<size_t> expected_parts; for (unsigned int i = 0; i < test_map.num_partitions(); i++) { expected_parts.push_back(range*i); } vector<size_t> actual_parts = test_map.get_partitions(); EXPECT_THAT(actual_parts, ContainerEq(expected_parts)); Range<size_t> range1(0, range - 1); Range<size_t> range2(range, range*2 - 1); Range<size_t> range3(range*2, range*3 - 1); Range<size_t> range4(range*3, numeric_limits<size_t>::max()); node_range_type range1_node1 = std::make_pair(node1, range1); node_range_type range2_node1 = std::make_pair(node1, range2); node_range_type range3_node1 = std::make_pair(node1, range3); node_range_type range4_node1 = std::make_pair(node1, range4); node_range_type tmp; EXPECT_TRUE(test_map.get_range(range/2, &tmp).ok()); EXPECT_EQ(range1_node1, tmp); EXPECT_TRUE(test_map.get_range(range + range/2, &tmp).ok()); EXPECT_EQ(range2_node1, tmp); EXPECT_TRUE(test_map.get_range(range*2 + range/2, &tmp).ok()); EXPECT_EQ(range3_node1, tmp); EXPECT_TRUE(test_map.get_range(range*3 + range/2, &tmp).ok()); EXPECT_EQ(range4_node1, tmp); }
void addSolution(const Permutation& sol) { permutations.push_back(sol); D_ASSERT(sol.size() == orbit_mins.size()); debug_out(3, "SS", "Old orbit_mins:" << orbit_mins); for(int i : range1(sol.size())) { if(sol[i] != i) { int val1 = walkToMinimum(i); int val2 = walkToMinimum(sol[i]); int orbit_min = -1; if(comparison(val1, val2)) orbit_min = val1; else orbit_min = val2; update_orbit_mins(orbit_min, val1); update_orbit_mins(orbit_min, val2); update_orbit_mins(orbit_min, i); update_orbit_mins(orbit_min, sol[i]); } } debug_out(1, "SS", "Solution found"); debug_out(3, "SS", "Sol:" << sol); debug_out(3, "SS", "New orbit_mins:" << orbit_mins); }
SplitState filterGraph(PartitionStack* ps, const GraphType& points, const CellList& cells, int path_length) { // Would not normally go this low level, but it is important this is fast memset(&(mset.front()), 0, mset.size() * sizeof(mset[0])); edgesconsidered = 0; MonoSet monoset(ps->cellCount()); debug_out(3, "EdgeGraph", "filtering: " << cells.size() << " cells out of " << ps->cellCount()); if(path_length == 1) { for(int c : cells) { hashCellSimple(ps, points, monoset, c); } } else { MonoSet hitvertices(ps->domainSize()); for(int c : cells) { hashRangeDeep(ps, points, monoset, hitvertices, ps->cellRange(c)); } memset(&(msetspare.front()), 0, msetspare.size() * sizeof(msetspare[0])); hashRangeDeep2(ps, points, monoset, hitvertices.getMembers()); for(int i : range1(mset.size())) { mset[i] += msetspare[i] * 71; } } debug_out(3, "EdgeGraph", "filtering " << mset << " : " << monoset); return filterPartitionStackByFunctionWithCells(ps, SquareBrackToFunction(&mset), monoset); }
virtual int advise_branch() { int best_cell = -1; int best_neighbours = 0; int best_size = std::numeric_limits<int>::max(); for(int i : range1(ps->cellCount())) { if(ps->cellSize(i) > 1) { advise_branch_monoset.clear(); int cellfirstmem = *(ps->cellStartPtr(i)); for(const auto& edge : points.neighbours(cellfirstmem)) { int cell = ps->cellOfVal(edge.target()); if(ps->cellSize(cell) > 1) advise_branch_monoset.add(cell); } if(advise_branch_monoset.size() > best_neighbours || (advise_branch_monoset.size() == best_neighbours && ps->cellSize(i) < best_size) ) { best_cell = i; best_neighbours = advise_branch_monoset.size(); best_size = ps->cellSize(i); } } } return best_cell; }
SplitState filterPartitionStackByUnorderedFunction(PartitionStack* ps, F f) { debug_out(3, "filterUnFun", "prestate " << ps->printCurrentPartition()); int cellCount = ps->cellCount(); // first of all, we need to try to distinguish as many values of F as possible. std::map<typename F::result_type, HashType> full_hash; for(int i : range1(cellCount)) { typedef std::map<typename F::result_type, unsigned> map_type; map_type count_map; for(int x : ps->cellRange(i)) { count_map[f(x)]++; } for(const auto& m : count_map) { full_hash[m.first] = hash_combine(full_hash[m.first], i, m.second); } } debug_out(3, "filter", "Hash:" << full_hash); debug_out(3, "filter", "Function:" << f); SplitState ret = filterPartitionStackByFunction(ps, IndirectFunction(MapToFunction(&full_hash), f)); debug_out(3, "filterUnFun", "poststate " << ps->printCurrentPartition()); return ret; }
TEST(ustl_forward_list, constructors) { // default: ustl::forward_list<int> l1; l1.insert_after(l1.before_begin(), 3); ASSERT_EQ(3, l1.front()); // fill: ustl::forward_list<int> fill1(ustl::forward_list<int>::size_type(10)); auto it1 = fill1.begin(); for (size_t i = 0; i < 10; i++) ASSERT_EQ(*it1++, 0); ustl::forward_list<int> fill2(ustl::forward_list<int>::size_type(10), static_cast<int>(-1)); auto it2 = fill2.begin(); for (size_t i = 0; i < 10; i++) ASSERT_EQ(*it2++, -1); // range: ustl::vector<int> v1{1, 2, 3}; ustl::forward_list<int> range1(v1.begin(), v1.end()); const ustl::forward_list<int> range1a{1, 2, 3}; ASSERT_TRUE(range1 == range1a); // copy: ustl::forward_list<int> copy1(range1); ASSERT_TRUE(copy1 == range1a); // initializer list: ustl::forward_list<int> l2{1, 2, 3, 4, 5}; const ustl::forward_list<int> l3{1, 2, 3, 4, 5}; ASSERT_TRUE(l2 == l3); }
SplitState filterPartitionStackByUnorderedListFunction(PartitionStack* ps, F f) { debug_out(3, "filterUnListFun", "prestate " << ps->printCurrentPartition()); int cellCount = ps->cellCount(); // first of all, we need to try to distinguish as many values of F as possible. std::map<typename F::result_type::value_type, HashType> full_hash; for(int i : range1(cellCount)) { typedef std::map<typename F::result_type::value_type, unsigned> map_type; map_type count_map; for(int val : ps->cellRange(i)) { for(const auto& val2 : f(val)) count_map[val2]++; } for(const auto& val : count_map) { full_hash[val.first] = hash_combine(full_hash[val.first], i, val.second); } } SplitState ret = filterPartitionStackByFunction(ps, IndirectVecCollapseFunction(MapToFunction(&full_hash), f)); debug_out(3, "filterUnListFun", "poststate " << ps->printCurrentPartition()); return ret; }
void clean() { for(int i : range1(graph_size)) { std::set<UncolouredEdge> e(edges[i].begin(), edges[i].end()); edges[i] = vec1<UncolouredEdge>(e.begin(), e.end()); } }
bool check_transversal(const vec1<Permutation>& trans, int start, int end) { for(int i : range1(trans.size())) { start = trans[i][start]; } return start == end; }
virtual bool verifySolution(const Permutation& p) { for(int i : range1(points.size())) { if(p[points[i]] != points[i]) return false; } return true; }
inline vec1<int> invertVecAsPermutation(const vec1<int>& v) { vec1<int> ret(v.size()); for(int i : range1(v.size())) { ret[v[i]] = i; } return ret; }
TEST_F(SimplifiedBackwardsTextIteratorTest, characterAt) { const char* bodyContent = "<a id=host><b id=one>one</b> not appeared <b id=two>two</b></a>"; const char* shadowContent = "three <content select=#two></content> <content select=#one></content> " "zero"; setBodyContent(bodyContent); setShadowContent(shadowContent, "host"); Element* host = document().getElementById("host"); EphemeralRangeTemplate<EditingStrategy> range1( EphemeralRangeTemplate<EditingStrategy>::rangeOfContents(*host)); SimplifiedBackwardsTextIteratorAlgorithm<EditingStrategy> backIter1( range1.startPosition(), range1.endPosition()); const char* message1 = "|backIter1| should emit 'one' and 'two' in reverse order."; EXPECT_EQ('o', backIter1.characterAt(0)) << message1; EXPECT_EQ('w', backIter1.characterAt(1)) << message1; EXPECT_EQ('t', backIter1.characterAt(2)) << message1; backIter1.advance(); EXPECT_EQ('e', backIter1.characterAt(0)) << message1; EXPECT_EQ('n', backIter1.characterAt(1)) << message1; EXPECT_EQ('o', backIter1.characterAt(2)) << message1; EphemeralRangeTemplate<EditingInFlatTreeStrategy> range2( EphemeralRangeTemplate<EditingInFlatTreeStrategy>::rangeOfContents( *host)); SimplifiedBackwardsTextIteratorAlgorithm<EditingInFlatTreeStrategy> backIter2( range2.startPosition(), range2.endPosition()); const char* message2 = "|backIter2| should emit 'three ', 'two', ' ', 'one' and ' zero' in " "reverse order."; EXPECT_EQ('o', backIter2.characterAt(0)) << message2; EXPECT_EQ('r', backIter2.characterAt(1)) << message2; EXPECT_EQ('e', backIter2.characterAt(2)) << message2; EXPECT_EQ('z', backIter2.characterAt(3)) << message2; EXPECT_EQ(' ', backIter2.characterAt(4)) << message2; backIter2.advance(); EXPECT_EQ('e', backIter2.characterAt(0)) << message2; EXPECT_EQ('n', backIter2.characterAt(1)) << message2; EXPECT_EQ('o', backIter2.characterAt(2)) << message2; backIter2.advance(); EXPECT_EQ(' ', backIter2.characterAt(0)) << message2; backIter2.advance(); EXPECT_EQ('o', backIter2.characterAt(0)) << message2; EXPECT_EQ('w', backIter2.characterAt(1)) << message2; EXPECT_EQ('t', backIter2.characterAt(2)) << message2; backIter2.advance(); EXPECT_EQ(' ', backIter2.characterAt(0)) << message2; EXPECT_EQ('e', backIter2.characterAt(1)) << message2; EXPECT_EQ('e', backIter2.characterAt(2)) << message2; EXPECT_EQ('r', backIter2.characterAt(3)) << message2; EXPECT_EQ('h', backIter2.characterAt(4)) << message2; EXPECT_EQ('t', backIter2.characterAt(5)) << message2; }
void make_symmetric() { for(int i : range1(graph_size)) { for(int j = 1; j <= edges[i].size(); ++j) { edges[edges[i][j].target()].push_back(UncolouredEdge(j)); } } }
vec1<int> getMins() const { vec1<int> minimums; for(int i : range1(orbit_mins.size())) { if(isMinimum(i)) minimums.push_back(i); } return minimums; }
SplitState fix_buildingRBase(const vec1<int>& fixed_values, bool useOrbits, bool useBlocks, bool useOrbitals, bool rootCall = false) { debug_out(3, "scpg", "last depth " << last_depth.get() << " new depth " << fixed_values.size()); D_ASSERT(fixed_values.size() > last_depth.get()); last_depth.set(fixed_values.size()); if(useOrbits) { doCacheCheck(config.useOrbits, tracking_first_found_orbits, [this](const vec1<int>& v){ return this->fillRBaseOrbitPartitionCache(v); }, fixed_values, "orbits"); } if(useBlocks) { doCacheCheck(config.useBlocks, tracking_first_found_blocks, [this](const vec1<int>& v){ return this->fillRBaseBlocksCache(v); }, fixed_values, "blocks"); } if(useOrbitals) { doCacheCheck(config.useOrbitals, tracking_first_found_orbitals, [this](const vec1<int>& v){ return this->fillRBaseOrbitalsCache(v); }, fixed_values, "orbitals"); } SplitState ss(true); int fixed_size = fixed_values.size(); if(useOrbits) { const vec1<int>* part = 0; if(tracking_first_found_orbits.get() >= 0) part = this->getRBaseOrbitPartition_cached(tracking_first_found_orbits.get()); else part = this->getRBaseOrbitPartition_cached(fixed_size); debug_out(3, "scpg", "fix_rBase:orbits"); if(!part->empty()) ss = filterPartitionStackByFunction(ps, SquareBrackToFunction(part)); if(ss.hasFailed()) return ss; } if( ( StabChainConfig::doConsiderIfNonTrivial(config.useOrbitals) && fixed_size == tracking_first_found_orbitals.get() ) || ( config.useOrbitals == StabChainConfig::always ) || ( rootCall ) ) { return signal_changed_generic(range1(ps->cellCount()), identityPermutation()); } return ss; }
vec1<vec1<int> > getOrbitsPartition(int dom) const { if(!hasOrbit()) { vec1<vec1<int> > v(dom); for(int i : range1(v.size())) v[i].push_back(i); return v; } else return GAP_get<vec1<vec1<int> > >(GAP_callFunction(FunObj_getOrbitPart, sc, GAP_make(dom))); }
SplitState filterPartitionStackByFunction_noSortData(PartitionStack* ps, F f) { PartitionEvent pe; int cellCount = ps->cellCount(); for(int i : range1(cellCount)) { filterCell(ps, f, i, &pe); } pe.finalise(); ps->getAbstractQueue()->addPartitionEvent(std::move(pe)); return SplitState(true); }
vec1<optional<Permutation> > getTransversal() const { vec1<optional<int> > translabels(getTranslabels()); vec1<Permutation> labels(getLabels()); vec1<optional<Permutation> > p(translabels.size(), optional<Permutation>()); for(int i : range1(translabels.size())) { if(translabels[i]) { p[i] = labels[*(translabels[i])]; } } return p; }
const vec1<std::map<int,int> >* fillRBaseBlocksCache(const vec1<int>& fix) { vec1<vec1<vec1<int> > > blocks = scc.blocks(fix); vec1<std::map<int,int> > block_functions; for(int i : range1(blocks.size())) { block_functions.push_back(partitionToMap(blocks[i])); } if(original_blocks.size() < fix.size() + 1) original_blocks.resize(fix.size() + 1); original_blocks[fix.size() + 1] = std::move(block_functions); return &(original_blocks[fix.size() + 1]); }
inline std::map<int, int> partitionToMap(const vec1<vec1<int> >& part) { std::map<int, int> m; int covered = 1; for(int i : range1(part.size())) { for(int val : part[i]) { D_ASSERT(m[val] == 0); m[val] = i; covered++; } } return m; }
void ofApp::setup() { ofxNet::IPAddressRange range0; ofxNet::IPAddressRange range1(Poco::Net::IPAddress("192.168.0.1")); ofxNet::IPAddressRange range2(Poco::Net::IPAddress("192.168.0.33"), 23); ofxNet::IPAddressRange range3("2001:0db8:85a3::8a2e:0370:7334/64"); ofxNet::IPAddressRange range4("192.168.5.219/28"); ofxNet::IPAddressRange range5("2001:0db8:85a3::8a2e:0370:7334"); ofxNet::IPAddressRange range6("0.0.0.0/31"); std::cout << toString(range0); std::cout << "-----" << std::endl; std::cout << toString(range1); std::cout << "-----" << std::endl; std::cout << toString(range2); std::cout << "-----" << std::endl; std::cout << toString(range3); std::cout << "-----" << std::endl; std::cout << toString(range4); std::cout << "-----" << std::endl; std::cout << toString(range5); std::cout << "-----" << std::endl; Poco::Net::IPAddress test0("192.168.0.1"); Poco::Net::IPAddress test1("2001:0db8:85a3::8a2e:0370:7334"); Poco::Net::IPAddress test2("127.0.0.2"); Poco::Net::IPAddress test3("10.10.10.2"); Poco::Net::IPAddress test4("::FFFF"); Poco::Net::IPAddress test5("0.0.0.1"); std::cout << toString(range0, test0) << std::endl; std::cout << toString(range0, test1) << std::endl; std::cout << toString(range0, test2) << std::endl; std::cout << toString(range0, test3) << std::endl; std::cout << toString(range0, test4) << std::endl; std::cout << toString(range0, test4) << std::endl; std::cout << toString(range0, test5) << std::endl; std::cout << toString(range6, test5) << std::endl; ofxNet::IPAddressRange a("192.168.5.219/28"); ofxNet::IPAddressRange b("192.168.5.219/27"); std::cout << toString(a, b) << std::endl; std::cout << toString(b, a) << std::endl; }
SplitState filterPartitionStackByFunction_withSortData(PartitionStack* ps, F f) { PartitionEvent& pe = ps->getAbstractQueue()->getPartitionEvent(); int len = 0; for(auto it = pe.order.begin(); it != pe.order.end(); ++it) { len++; if(it->change) { int cell = pe.change_cells[it->index].first; bool sorter = indirect_data_sorter(cell, ps, f, pe.change_cells[it->index].second); ps->fixCellInverses(cell); if(!sorter) { debug_out(3, "filterPSBF_WSD", "failed " << cell); pe.order.promote(it); return SplitState(false); } } else { if(!validateFixedCell(ps, pe.no_change_cells[it->index].first, pe.no_change_cells[it->index].second, f)) { pe.order.promote(it); debug_out(3, "filterPSBF_WSD", "failed validate fixed cell"); return SplitState(false); } } } // Finally, do the splits for(int i : range1(pe.change_cells.size())) { int cell = pe.change_cells[i].first; const SortEvent& se = pe.change_cells[i].second; for(int j = 1; j < se.hash_starts.size(); ++j) { if(ps->split(cell, se.hash_starts[j].startPos).hasFailed()) { abort(); } } } return SplitState(true); }
virtual bool verifySolution(const Permutation& p) { for(int i : range1(points.vertices())) { const vec1<VertexType>& p_i = points.neighbours(i); vec1<VertexType> image_set; for(const auto& edge : p_i) { int pnt = edge.target(); int pnt_image = p[pnt]; image_set.push_back(VertexType(pnt_image, edge.colour())); } std::sort(image_set.begin(), image_set.end()); if(points.neighbours(p[i]) != image_set) { return false; } } return true; }
void initalize(const vec1<int>& order) { D_ASSERT(!fixed_base); fixed_base = true; unpacked_stabChain_depth.resize(order.size()); GAP_callFunction(FunObj_ChangeStabChain, stabChain, GAP_make(order)); debug_out(1, "SCC", "Setting up cache"); debug_out(3, "SCC", "Order " << order); int order_pos = 1; GAPStabChainWrapper stabChainCpy(stabChain); do { StabChainLevel scl(stabChainCpy); while(order[order_pos] != scl.base_value) { debug_out(3, "SCC", "Skipping depth " << order_pos); order_pos++; } debug_out(3, "SCC", "Setting depth "<<order_pos<<" base point "<<scl.base_value); levels.push_back(scl); unpacked_stabChain_depth[order_pos] = levels.size(); stabChainCpy = stabChainCpy.getNextLevel(); } while(stabChainCpy.hasNextLevel()); #ifndef NO_DEBUG for(int i : range1(unpacked_stabChain_depth.size())) { if(unpacked_stabChain_depth[i] != 0) { D_ASSERT(levels[unpacked_stabChain_depth[i]].base_value == order[i]); } } #endif }
const vec1<int>* fillRBaseOrbitPartitionCache(const vec1<int>& fix) { debug_out(3, "scpg", "Fixing: "<< fix); vec1<vec1<int> > oart = scc.orbits(fix, ps->domainSize()); debug_out(3, "scpg", "Got orbit partition" << oart); // This might not be necessary, but it doesn't hurt! for(int i : range1(oart.size())) std::sort(oart[i].begin(), oart[i].end()); std::sort(oart.begin(), oart.end()); vec1<int> filter; if(oart.size() > 1) filter = partitionToList(oart, ps->domainSize(), MissingPoints_Fixed); debug_out(3, "scpg", "Filter partition: "<< filter); if(original_partitions.size() < fix.size() + 1) original_partitions.resize(fix.size() + 1); original_partitions[fix.size()+1] = std::move(filter); return &(original_partitions[fix.size() + 1]); }
void test3(){ SimplePrng p; int i; Int v; double d1; double *ptr1, *ptr2; int inrange = 0; Int range1(5000); Int range2(9000); Int maxv(-1); int res1, res2; Int tmpint; for (int j=1; j < TEST3_NOPS; ++j){ // insert elements for (i = 0; i < TEST3_NINSERT; ++i){ v = Int(p.next() % TEST3_RANGE); if (maxv.val < v.val) maxv = v; if (range1.val <= v.val && v.val <= range2.val) ++inrange; // count number to be deleted test3_sl.insert(v, (double)v.val); //test3_sl.insert(&v, new double(v)); } // copy skiplist SkipList<Int,double> sl2(test3_sl); Int todel; int n1, n2; // delete elements for (i = 0; i < TEST3_NDELETE; ++i){ todel = Int(p.next() % TEST3_RANGE); n1 = 0; while (!test3_sl.lookupRemove(todel,0, d1)){ assert((int)d1 == todel.val); ++n1; } n2 = sl2.delRange(todel, 1, todel, 1, 0, 0); assert(n1 == n2); } // check elements for (i=0; i < TEST3_RANGE; ++i){ tmpint.val = i; res1 = test3_sl.lookup(tmpint, ptr1); res2 = sl2.lookup(tmpint, ptr2); assert (res1==res2); if (res1==0) assert(*ptr1==*ptr2); } SkipListNode<Int,double> *it1, *it2; it1 = test3_sl.getFirst(); it2 = sl2.getFirst(); while (it1 != test3_sl.getLast()){ assert(it2 != test3_sl.getLast()); assert(it1->key.val == it2->key.val); assert(it1->value == it2->value); it1 = test3_sl.getNext(it1); it2 = test3_sl.getNext(it2); } assert(it2 == sl2.getLast()); // clear lists test3_sl.clear(0, 0); sl2.clear(0, 0); } }
TEST_F(SimplifiedBackwardsTextIteratorTest, copyTextTo) { const char* bodyContent = "<a id=host><b id=one>one</b> not appeared <b id=two>two</b></a>"; const char* shadowContent = "three <content select=#two></content> <content select=#one></content> " "zero"; setBodyContent(bodyContent); setShadowContent(shadowContent, "host"); Element* host = document().getElementById("host"); const char* message = "|backIter%d| should have emitted '%s' in reverse order."; EphemeralRangeTemplate<EditingStrategy> range1( EphemeralRangeTemplate<EditingStrategy>::rangeOfContents(*host)); SimplifiedBackwardsTextIteratorAlgorithm<EditingStrategy> backIter1( range1.startPosition(), range1.endPosition()); BackwardsTextBuffer output1; backIter1.copyTextTo(&output1, 0, 2); EXPECT_EQ("wo", String(output1.data(), output1.size())) << String::format(message, 1, "wo").utf8().data(); backIter1.copyTextTo(&output1, 2, 1); EXPECT_EQ("two", String(output1.data(), output1.size())) << String::format(message, 1, "two").utf8().data(); backIter1.advance(); backIter1.copyTextTo(&output1, 0, 1); EXPECT_EQ("etwo", String(output1.data(), output1.size())) << String::format(message, 1, "etwo").utf8().data(); backIter1.copyTextTo(&output1, 1, 2); EXPECT_EQ("onetwo", String(output1.data(), output1.size())) << String::format(message, 1, "onetwo").utf8().data(); EphemeralRangeTemplate<EditingInFlatTreeStrategy> range2( EphemeralRangeTemplate<EditingInFlatTreeStrategy>::rangeOfContents( *host)); SimplifiedBackwardsTextIteratorAlgorithm<EditingInFlatTreeStrategy> backIter2( range2.startPosition(), range2.endPosition()); BackwardsTextBuffer output2; backIter2.copyTextTo(&output2, 0, 2); EXPECT_EQ("ro", String(output2.data(), output2.size())) << String::format(message, 2, "ro").utf8().data(); backIter2.copyTextTo(&output2, 2, 3); EXPECT_EQ(" zero", String(output2.data(), output2.size())) << String::format(message, 2, " zero").utf8().data(); backIter2.advance(); backIter2.copyTextTo(&output2, 0, 1); EXPECT_EQ("e zero", String(output2.data(), output2.size())) << String::format(message, 2, "e zero").utf8().data(); backIter2.copyTextTo(&output2, 1, 2); EXPECT_EQ("one zero", String(output2.data(), output2.size())) << String::format(message, 2, "one zero").utf8().data(); backIter2.advance(); backIter2.copyTextTo(&output2, 0, 1); EXPECT_EQ(" one zero", String(output2.data(), output2.size())) << String::format(message, 2, " one zero").utf8().data(); backIter2.advance(); backIter2.copyTextTo(&output2, 0, 2); EXPECT_EQ("wo one zero", String(output2.data(), output2.size())) << String::format(message, 2, "wo one zero").utf8().data(); backIter2.copyTextTo(&output2, 2, 1); EXPECT_EQ("two one zero", String(output2.data(), output2.size())) << String::format(message, 2, "two one zero").utf8().data(); backIter2.advance(); backIter2.copyTextTo(&output2, 0, 3); EXPECT_EQ("ee two one zero", String(output2.data(), output2.size())) << String::format(message, 2, "ee two one zero").utf8().data(); backIter2.copyTextTo(&output2, 3, 3); EXPECT_EQ("three two one zero", String(output2.data(), output2.size())) << String::format(message, 2, "three two one zero").utf8().data(); }
ListStab(const vec1<int>& _points, PartitionStack* ps) : AbstractConstraint(ps), points(_points), inv_points(ps->domainSize(), 0) { for(int i : range1(points.size())) inv_points[points[i]] = i; }