/*! @brief Adapter for SIMD read-only range Convert an existing range specified by two iterators into a SIMD aware read-only iterator returning SIMD pack of optimal cardinal for current architecture. @usage_output{memory/output_range.cpp,memory/output_range.out} @param r A Range addressing a contiguous memory block @return An instance of output_range **/ template<class Iterator> inline boost::iterator_range< output_iterator<Iterator> > output_range( Iterator begin, Iterator end ) { BOOST_ASSERT_MSG ( is_aligned(std::distance(begin,end) , output_iterator<Iterator>::cardinal) , "Range being adapted holds a non integral number of SIMD pack." ); return boost::make_iterator_range( output_begin(begin), output_end(end) ); }
int main() { std::string word; std::vector<std::string> WordVector; std::vector<std::string> ReversedWordVector; //Reverse the initial text file std::ifstream input_file("TheReverseWordTest.txt", std::ios_base::binary); std::ofstream output_file("TheReverseWordTest_reversed.txt", std::ios_base::binary); std::istreambuf_iterator<char> input_begin(input_file); std::istreambuf_iterator<char> input_end; std::ostreambuf_iterator<char> output_begin(output_file); std::vector<char> input_data(input_begin, input_end); std::reverse_copy(input_data.begin(), input_data.end(), output_begin); input_file.close(); output_file.close(); //Construct a vector of words std::ifstream TestFile("TheReverseWordTest.txt"); while (TestFile >> word) { WordVector.push_back(word); } TestFile.close(); //Construct a vector of reversed words std::ifstream ReversedFile("TheReverseWordTest_reversed.txt"); while (ReversedFile >> word) { ReversedWordVector.push_back(word); } ReversedFile.close(); // Allocate space for intersection std::vector<std::string> IntersectionVector; // Sort as required by std::set_intersection std::sort(WordVector.begin(), WordVector.end()); std::sort(ReversedWordVector.begin(), ReversedWordVector.end()); // Compute the set intersection std::set_intersection(WordVector.begin(), WordVector.end(), ReversedWordVector.begin(), ReversedWordVector.end(), std::back_inserter(IntersectionVector)); std::ofstream myfile; myfile.open ("uniquepairs.txt"); for (std::string n : IntersectionVector) myfile<< n << std::endl; myfile.close(); return 0; }
int ip_output(void *pbuf, uint16_t plen, void *dbuf, uint16_t dlen) { oiph.id = htons_inc(ip_id); oiph.ttl = IP_TTL; oiph.check = 0; oiph.version = 4; /* Options not supported */ oiph.ihl = 5; oiph.check = ip_checksum(&oiph, sizeof(oiph)); output_begin(); /* Set up output buffer (space left for header) */ output_add(&oiph, 4 * oiph.ihl); output_add(pbuf, plen); ouput_add(dbuf, dlen); if (LOOPBACK(oiph.daddr) || oiph.daddr == ip_addr) return loopback_queue(); else return mac_queue(); /* We do blocking writes, when this code returns the buffer is on the wire and we don't have to fret about re-use. Does mean slip has to be careful to buffer the receive side while queueing output */ }