diff --git a/public/consolidated/cpp.json b/public/consolidated/cpp.json index 4be5f18e..71066e57 100644 --- a/public/consolidated/cpp.json +++ b/public/consolidated/cpp.json @@ -17,6 +17,24 @@ } ] }, + { + "categoryName": "Data Structure Conversion", + "snippets": [ + { + "title": "Vector to Queue", + "description": "Convert vector into queue quickly", + "author": "mrityunjay2003", + "tags": [ + "cpp", + "data structures", + "queue", + "vector" + ], + "contributors": [], + "code": "#include\n#include\n#include\n\nstd::queue vectorToQueue(const std::vector& v) {\n return std::queue(std::deque(v.begin(), v.end()));\n}\n" + } + ] + }, { "categoryName": "Math And Numbers", "snippets": [ diff --git a/snippets/cpp/data-structure-conversion/vector-to-queue.md b/snippets/cpp/data-structure-conversion/vector-to-queue.md new file mode 100644 index 00000000..e31d90fe --- /dev/null +++ b/snippets/cpp/data-structure-conversion/vector-to-queue.md @@ -0,0 +1,16 @@ +--- +title: Vector to Queue +description: Convert vector into queue quickly +tags: cpp, data structures,queue,vector +author: mrityunjay2003 +--- + +```cpp +#include +#include +#include + +std::queue vectorToQueue(const std::vector& v) { + return std::queue(std::deque(v.begin(), v.end())); +} +``` \ No newline at end of file