When.com Web Search

Search results

  1. Results From The WOW.Com Content Network
  2. c++ - Read file into vector<byte> - Code Review Stack Exchange

    codereview.stackexchange.com/questions/222021

    \$\begingroup\$ Creating byte data[length]; then creating a vector forces a copy. Why not make data a vector and simply return it. Then the compiler can do lots of optimization and build the vector directly at the destination so removing the need for a copy. \$\endgroup\$ –

  3. c++ - Vector-transposing function - Code Review Stack Exchange

    codereview.stackexchange.com/questions/214971/vector-transposing-function

    I profiled a library I'm writing that uses vector transposes and found that I am spending a good bit of time doing the following transpose. I am using a std::vector of std::vector&lt;double&gt;s to

  4. Implement Own Vector Class in C++ - Code Review Stack Exchange

    codereview.stackexchange.com/questions/221707/implement-own-vector-class-in-c

    10. I am preparing for an interview and came to know about this question: implement a vector class in C++. I thought of how I would write it an interview and included the code below. The things I know I did not cover already are: 1) No use of templates for different data types 2) No use of iterators for iterating.

  5. c++ - Filter out elements from std::vector - Code Review Stack...

    codereview.stackexchange.com/questions/175713

    I have ended up with the following code in order to filter out some bad elements from a std::vector: #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;algorithm&gt; typedef struct my...

  6. Create a C style char** from a C++ vector<string>

    codereview.stackexchange.com/.../create-a-c-style-char-from-a-c-vectorstring

    The only difficulty is ensuring this isn't used after the owning vector goes out of scope. The simplest implementation is something like: std::vector<char*> strlist(std::vector<std::string> &input) {. std::vector<char*> result; // remember the nullptr terminator. result.reserve(input.size()+1);

  7. C++ Vector with templates - Code Review Stack Exchange

    codereview.stackexchange.com/questions/204879/c-vector-with-templates

    I am learning about templates in C++ so I decided to implement an N-dimensional vector. The code seems to work fine, but there are a few things that I am unsure about. To stop GetW() being called on a 3-dimensional vector, I used std::enable_if .

  8. c++ - Longest string in a vector - Code Review Stack Exchange

    codereview.stackexchange.com/questions/71877/longest-string-in-a-vector-two...

    The first version of the algorithm uses a traditional C++03-era for loop with iterators. The only modern element is the auto used to deduce an std::vector<std::string>::iterator. The second loop uses a C++11 range-based for loop whose syntax is close to the one used in Java.

  9. c++ - Storing words from an input stream into a vector - Code...

    codereview.stackexchange.com/.../storing-words-from-an-input-stream-into-a-vector

    11. I'm extremely new to C++ and am doing the exercises on the book Accelerated C++. Here is one of the exercises: 4-5. Write a function that reads words from an input stream and stores them in a vector. Use that function both to write programs that count the number of words in the input, and to count how many times each word occurred.

  10. c++ - Basic iterator supporting vector implementation - Code...

    codereview.stackexchange.com/questions/202157/basic-iterator-supporting-vector...

    The implementation of an iterator is based on the "Iterator Concept". There are actually five types of iterator in C++. But since you are using vector as your example implementation we should consider the "Random Access Iterator Concept". To qualify as a random access iterator you have to uphold a specific contract.

  11. Most efficient way to find an entry in a C++ vector

    codereview.stackexchange.com/.../most-efficient-way-to-find-an-entry-in-a-c-vector

    If the data can be sorted and de-duplicated, then the most efficient way to find an entry is to store the data in a std::set. Storing the data takes a little longer (O (log n) for the set vs. amortized O (1) for the vector), but finding the data makes up for it (O (log n) for the set vs. O (n) for the vector).