enow.com Web Search

Search results

  1. Results from the WOW.Com Content Network
  2. Implement Own Vector Class in C++ - Code Review Stack Exchange

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

    Your Vector::operator[] return a vector&. Your insert is empty and uses an undefined type iterator. You have a data member and a member function sharing the same name size. Your destructor is ~vector instead of ~Vector. And there are a lot of compile errors left. \$\endgroup\$ –

  3. c++ - Read file into vector<byte> - Code Review Stack Exchange

    codereview.stackexchange.com/questions/222021/read-file-into-vectorbyte

    \$\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\$ –

  4. c++ - Sorting multiple vectors based on a reference vector - Code...

    codereview.stackexchange.com/questions/235764/sorting-multiple-vectors-based...

    I am trying to sort vectors based on a reference vector. First I am getting the indexes for the reference vector and then using that I am doing inplace sorting for the rest of the vectors. #includ...

  5. 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 .

  6. 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

    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). If you use a set, make sure to use set's find function (e.g. mySet.find(tableNum) rather than std::find(mySet.begin(),mySet.end(),tableNum) ), or there's no benefit.

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

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

    I am dealing with some older C style APIs, like Posix execve that take a char**. In the rest of my code, I prefer to use a fairly modern C++ style, so I have vector of std::string.

  8. c++ - contains() algorithm for std::vector - Code Review Stack...

    codereview.stackexchange.com/questions/59997/contains-algorithm-for-stdvector

    Another obvious possibility would be to continue to store the data in a vector, but keep the vector sorted so you can do the search with std::binary_search. Right now this is O(N). Using std::set or a sorted vector with std::binary_search will reduce that to O(log N).

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

    codereview.stackexchange.com/questions/214971

    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

  10. c++ - Printing out vector<string> char by char - Code Review...

    codereview.stackexchange.com/questions/139841/printing-out-vectorstring-char...

    I have learned a bit of C in university and I'm now learning C++ independently. I'm trying to print out std::vector<std::string> char by char. I know, that in C, strings are arrays and are terminated by '\0' terminator. Can I assume the same thing in c++? I use C++14. This works, but I'm unsure if it's the correct way to do this.

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

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

    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.