doc_id
stringlengths
36
36
metadata
dict
input
stringlengths
28
4.3k
output
stringlengths
11
5.45k
7cd04cbf-3005-4399-8ed6-ba597018cbfe
{ "language": "C++" }
```c++ ``` Add solution to task one using cstring Use char[] instead of string for demonstration
```c++ #include <iostream> #include <cstring> using namespace std; class Dog { char name[30]; public: Dog(const char _name[] = "") { strcpy(name, _name); } void greet() { cout << "Bark, bark! I am " << name << ", a talking dog." << endl; } }; class Person { char name[30]; ...
76211321-4e0a-4547-8b4f-a604380b7e14
{ "language": "C++" }
```c++ ``` Add test for getting the next non-null data token.
```c++ #include "humlib.h" using namespace std; using namespace hum; void processFile(HumdrumFile& infile); int main(int argc, char** argv) { Options options; options.process(argc, argv); HumdrumFileStream instream(options); HumdrumFile infile; while (instream.read(infile)) { processFile(infile); } return ...
6b6dc869-e138-4e70-9f39-b80ebed3af81
{ "language": "C++" }
```c++ ``` Add new test for timer class
```c++ // This is an open source non-commercial project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <thread> #include <cassert> #include <iostream> #include "../include/analyzer/Timer.hpp" int main(void) { analyzer::diagnostic::Timer tim...
ae57477b-06bb-4848-bfa1-e62c62dedbfc
{ "language": "C++" }
```c++ ``` Add a first choice for a GraphInput
```c++ #include <string> #include <iostream> #include "Graph.hh" #include "GraphInput.hh" using namespace std; template <typename V> class RawTextGraphInput : public GraphInput<string, V> { public: RawTextGraphInput(Graph<V>& g) : GraphInput<string, V>(g) {} void input(string path) { cout << "Fetching...
7d87cc23-7c82-4aa7-ac75-2a4a33d68d89
{ "language": "C++" }
```c++ ``` Add "flip a biased coin" sample
```c++ // Flip a biased coin #include <random> int main() { std::random_device random_device; std::mt19937 random_engine{random_device()}; std::bernoulli_distribution coin_distribution{0.25}; bool outcome = coin_distribution(random_engine); } // Generate a random boolean value according to a bernoulli // distri...
df14999f-b23b-49dc-ba9f-fd115e461a7e
{ "language": "C++" }
```c++ // Copyright 2012, Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
```c++ // Copyright 2012, Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
964b45cc-471c-47e2-a8d8-3c4333b4ab2d
{ "language": "C++" }
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" #include "base/logging.h" #if !defined(TOOLKIT_VIEWS) void ShowProximit...
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h" #include "base/logging.h" #if !defined(TOOLKIT_VIEWS) || !defined(USE_A...
ade9e073-81a0-400c-acac-a520de979d79
{ "language": "C++" }
```c++ ``` Add platform-independent wrapper function for isinf(). Patch contributed by Bill Wendling.
```c++ //===-- IsInf.cpp ---------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===-...
dfde4170-9e6c-4ef8-959d-60121f49889b
{ "language": "C++" }
```c++ ``` Add template insertion sort implementation.
```c++ #include <array> #include <iostream> template<typename T, std::size_t N> typename std::enable_if<N < 128 && std::is_integral<T>::value, void>::type insertion_sort(std::array<T, N>& array) { for (std::size_t i = 0; i < N; i++) { for (std::size_t j = i; j > 0 && array[j] < array[j-1]; j--) { std::swap(array...
32420e0b-bf2d-4c90-a6dd-b1bc637956f6
{ "language": "C++" }
```c++ ``` Add error test for inlined stages
```c++ #include "Halide.h" #include <stdio.h> using namespace Halide; int main(int argc, char **argv) { Func f, g; Var x, y; f(x) = x; f(x) += x; g(x) = f(x); // f is inlined, so this schedule is bad. f.vectorize(x, 4); g.realize(10); printf("There should have been an error\n")...
817b6fcb-a53f-4958-bc6a-02d0d16a9c26
{ "language": "C++" }
```c++ ``` Convert Sorted List to Binary Search Tree
```c++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ /** * Definition for a binary tree node. ...
cfaf13e1-0a0b-49f7-82e4-ab5b06270aed
{ "language": "C++" }
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ios/web/public/web_state/credential.h" namespace web { Credential::Credential() = default; Credential::~Credential() = default; } //...
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ios/web/public/web_state/credential.h" namespace web { Credential::Credential() : type(CREDENTIAL_TYPE_EMPTY) { } Credential::~Credent...
b1aaedca-93f1-4296-b78f-b39f0379ff60
{ "language": "C++" }
```c++ ``` Add Chapter 21, exercise 4
```c++ // Chapter 21, Exercise 4: implement count_if() yourself and test it #include "../lib_files/std_lib_facilities.h" //------------------------------------------------------------------------------ template<class In, class Pred> int my_count_if(In first, In last, const Pred& p) { int ctr = 0; while (fir...
c3ed2e07-c073-48cc-b10f-7c2e2cf47332
{ "language": "C++" }
```c++ ``` Solve SRM 144, Div 2, Problem ImageDithering
```c++ #include <iostream> #include <vector> #include <assert.h> using namespace std; class ImageDithering { public: int count(string dithered, vector<string> screen) { unsigned d[26]; for (int i = 0; i < 26; i++) { d[i] = 0; } for (unsigned i = 0; i < dithered.length(); i++) { d[dithered...
d0f22806-443b-44d1-bfe3-ad13c6c95d98
{ "language": "C++" }
```c++ ``` Implement tests and benchmarks for throttleCurve
```c++ #include "testHooks.h" #include "math/Algebra.h" /** * Built from a cubic function (a*x^3 + b*x^2 + c*x + d) defined at * f(-1) = 0 * f( 1) = 1 * f( 0) = hoverPoint * with the last degree of freedom setting the x^3 vs x balance * which corresponds to how "linear" the curve is ...
37143b38-40b9-49a0-81fd-2b3930a9e6b4
{ "language": "C++" }
```c++ ``` Add a new SkMemory implementation that uses mozalloc instead of malloc
```c++ /* * Copyright 2011 Google Inc. * Copyright 2012 Mozilla Foundation * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "SkTypes.h" #include "mozilla/mozalloc.h" #include "mozilla/mozalloc_abort.h" #include "mozilla/mozalloc_oom.h" void sk_...
3909e401-c0a8-48e6-9814-68b159331961
{ "language": "C++" }
```c++ ``` Implement good macro for iterate over an array.
```c++ #include <iterator> #define foreach (x,v) for (typeof(v).begin() x=(v).begin(); x!=(v).end(); ++x) using namespace std; int main(){ return 0; } ```
c74cc6bb-76b2-4712-bd82-ca0991f94bde
{ "language": "C++" }
```c++ ``` Add some tests for Dijkstra search
```c++ /// \file dijkstra.cpp /// /// Unit tests for the Dijkstra algorithm /// #include <iostream> #include <string> #include "../algorithms/dijkstra.hpp" #include "../handle.hpp" #include "catch.hpp" #include <sglib/hash_graph.hpp> namespace vg { namespace unittest { using namespace std; using sglib::HashGraph...
c17cfb99-71aa-4b21-8acc-ac15ed0bed6e
{ "language": "C++" }
```c++ ``` Add string_view c++17 feature example. Compile with -std=c++17 flags.
```c++ #include <iostream> #include <stdexcept> #include <string_view> void* operator new(std::size_t n) { std::cout << "new() " << n << " bytes\n"; return malloc(n); } int main() { std::string_view str_view("abcdef"); try { for (std::size_t i = 0; true; i++) { std::cout << i << ": " << str_view.at(i) << '\...
76d66871-f5a3-4a3d-8672-a9014cc76a80
{ "language": "C++" }
```c++ ``` Add a test case for r128957. It fixed a bug!
```c++ // RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s // Radar 9239104 class Class { public: //CHECK: DW_TAG_const_type int foo (int p) const { return p+m_int; } protected: int m_int; }; Class c; ```
d4df17b1-805b-400e-ad7b-35c84925cd75
{ "language": "C++" }
```c++ ``` Add example demonstrating saving nested hashmaps to binary file.
```c++ /* * * Example of dumping a map, containing values which are phmap maps or sets * building this requires c++17 support * */ #include <iostream> #include <parallel_hashmap/phmap_dump.h> template <class K, class V> class MyMap : public phmap::flat_hash_map<K, phmap::flat_hash_set<V>> { public: using Set...
3a4f5b5b-f825-42e2-a1c3-ad5d6e13db65
{ "language": "C++" }
```c++ ``` Add Chapter 25, Try This 1
```c++ // Chapter 25, Try This 1: demonstrate free store fragmentation... not much // to be seen here! #include<iostream> using namespace std; // type that requires a little more space than a Node struct Message { int a; int b; int c; }; // somewhat smaller type, but not half as small as a Message struc...
cdd4dce6-bf68-479c-9795-1b499a22c858
{ "language": "C++" }
```c++ ``` Add evaluation for postfix expression
```c++ /////////////////////////////////////// /// file: postexpr.cpp /// 计算后缀表达式 /////////////////////////////////////// #include <iostream> #include "sqstack.h" using namespace std; /// /// 执行计算 /// int Operate(int a, char theta, int b) { switch(theta) { case '+': return a+b; case '-': return a-b; c...
9f5ba97b-8924-4881-8f76-d51b437c5065
{ "language": "C++" }
```c++ ``` Add extra tests for [[gnu::...]] attributes, missed from r172382.
```c++ // RUN: %clang -cc1 -std=c++11 -verify %s // Error cases. [[gnu::this_attribute_does_not_exist]] int unknown_attr; // expected-warning@-1 {{unknown attribute 'this_attribute_does_not_exist' ignored}} int [[gnu::unused]] attr_on_type; // expected-warning@-1 {{attribute 'unused' ignored, because it is not attach...
9fc8a565-bb2c-42b2-a7ac-69593a5bf536
{ "language": "C++" }
```c++ ``` Delete the Middle Node of a Linked List
```c++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: ListNode* dele...
dca3b8cd-7576-4fd5-accf-b591eee3c820
{ "language": "C++" }
```c++ /* * Copyright (C) 2004-2011 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. */ #include <Python.h> void fail(PyObject* py, int n) {...
```c++ /* * Copyright (C) 2004-2011 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. */ #include <Python.h> #include <string> void fail(PyOb...
17187153-756a-4ea9-bbe5-2c7397004ffb
{ "language": "C++" }
```c++ ``` Add oss-fuzz endpoint for PathMeasure
```c++ /* * Copyright 2018 Google, LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "../Fuzz.h" void fuzz_PathMeasure(Fuzz* f); extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { auto fuzz = Fuzz(SkData::MakeWithou...
ae0cb4c3-c62e-4735-88d6-b947afe479d6
{ "language": "C++" }
```c++ ``` Add a test that uses coverage and printf from a DLL
```c++ // Test that coverage and MSVC CRT stdio work from a DLL. This ensures that the // __local_stdio_printf_options function isn't instrumented for coverage. // RUN: rm -rf %t && mkdir %t && cd %t // RUN: %clang_cl_asan -fsanitize-coverage=func -O0 %p/dll_host.cc -Fet.exe // RUN: %clang_cl_asan -fsanitize-coverage=...
e68bedb1-1985-4715-98ef-b7248aeba431
{ "language": "C++" }
```c++ ``` Use addition and multiplication rather than sqrt. Not much to gain.
```c++ #include <cmath> #include <ctime> #include <iostream> #include <vector> using namespace std; vector<long int> primes; void InitVector(long int s) { primes.reserve(s/10); primes.push_back(2); } int main(int argc, char const *argv[]) { clock_t begin = clock(); auto max = 10000000; auto lprime = 2; auto...
5d47a7c5-80dc-4e66-9ca2-775d09f75d71
{ "language": "C++" }
```c++ ``` Add solution to first part of first problem. 2D point structure with outer functions.
```c++ #include <iostream> #include <cmath> using namespace std; struct Point2D { double x; double y; }; Point2D translate(Point2D point, double dx, double dy) { Point2D translated; translated.x = point.x + dx; translated.y = point.y + dy; return translated; } double distanceBetween(Point2D firstPoint...
a5ef3ed1-977a-4b8b-9938-03969d7f1c69
{ "language": "C++" }
```c++ ``` Add Longest Palindrome Subsequence in DP
```c++ #include <bits/stdc++.h> #include <stdio.h> #include <string.h> using namespace std; int lps(char *str) { int n = strlen(str); int dp[n][n]; // Create a table to store results of subproblems // Strings of length 1 are palindrome of length 1 for (int i = 0; i < n; i++) dp[i][i] = 1; ...
b8724bfa-9e34-4be4-9cb7-1cc7d2200401
{ "language": "C++" }
```c++ ``` Add a test for ExternalCode functionality.
```c++ #include <stdio.h> #include "Halide.h" #include <fstream> #include <cassert> #include <iostream> #include "test/common/halide_test_dirs.h" using namespace Halide; int main(int argc, char **argv) { Var x("x"), y("y"); Func f("f"); f(x, y) = 42; std::string bitcode_file = Internal::get_test_tm...
949f5dcd-9f30-41d2-b5c9-b682f23e4529
{ "language": "C++" }
```c++ ``` Delete Node in a BST
```c++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* deleteNode(TreeNode* root, int key) { if(!root) return NULL; i...
6ad8ab7b-59e4-4a65-ad59-927d4075e4d7
{ "language": "C++" }
```c++ ``` Implement Expression tree to convert post fix expression in to an expression tree
```c++ #include <iostream> #include <string> #include <stack> using namespace std; struct ExpressionTree { char expr; ExpressionTree *left, *right; ExpressionTree(char opr) : expr(opr) { left = NULL; right = NULL; } }; bool isOperator(char opr) { return opr == '+' || opr == '-' || opr == '*' || opr == '/' |...
4cad21ea-ed65-436e-a551-a2d532aaf849
{ "language": "C++" }
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "sky/compositor/opacity_layer.h" namespace sky { namespace compositor { OpacityLayer::OpacityLayer() { } OpacityLayer::~OpacityLayer() ...
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "sky/compositor/opacity_layer.h" namespace sky { namespace compositor { OpacityLayer::OpacityLayer() { } OpacityLayer::~OpacityLayer() ...
ddf3004f-2c0b-46aa-9b85-16fbc1428ebe
{ "language": "C++" }
```c++ ``` Add C++ solution to multiples of 3 and 5 problem.
```c++ #include <iostream> int sum_of_multiples(int n){ int sum = 0; for(int i=3;i<n;i++){ if((i%3==0) || (i%5==0)) sum+=i; } return sum; } int main(){ std::cout << sum_of_multiples(1000); }```
890aa6ee-ef29-47d9-9dc0-150bb4ac1802
{ "language": "C++" }
```c++ ``` Add Chapter 4, exercise 1 (solution in O(N log N)
```c++ // 4.1 - determine if a binary tree is balanced, where "balanced" is defined as // "the subtrees of each node have a height differnce of no more than 1" // improve to have less calls to height(): have height() return -1 if the Node // it is called for is not balanced; it knows because it checks the heights of /...
aea02c6d-56cb-4493-af4c-00425097e3ca
{ "language": "C++" }
```c++ ``` Replace occurrences of "pi" with "3.14"
```c++ /* Objective: Given a string, compute recursively a new string where all appearances of "pi" have been replaced by "3.14". Time Complexity: O(N) Space Complexity: O(N) */ #include <iostream> using namespace std; #include <iostream> using namespace std; #include <bits/stdc++.h> void help(char inp...
2f61f838-b9ac-4ea9-af6c-b1ab9e8f5345
{ "language": "C++" }
```c++ ``` Add std2 type traits tests
```c++ #include <gtest/gtest.h> #include "std2_type_traits.hpp" namespace { struct NothrowMoveConstructible { NothrowMoveConstructible(NothrowMoveConstructible&&) noexcept = default; }; struct ThrowMoveConstructible { ThrowMoveConstructible(ThrowMoveConstructible&&) {}; }; struct NothrowMoveAssignable { No...
778d56b9-d13f-4288-955e-e5016250335c
{ "language": "C++" }
```c++ ``` Add basic example demonstrating access of attributes
```c++ /* * The MIT License (MIT) * * Copyright (c) 2016 Julian Ganz * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * t...
13d4dbc0-bc28-498f-aa57-2118294274ec
{ "language": "C++" }
```c++ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/ozone/public/gpu_platform_support.h" #include "base/logging.h" #include "ui/ozone/ozone_export.h" namespace ui { namespace { // No...
```c++ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/ozone/public/gpu_platform_support.h" #include "base/logging.h" #include "ui/ozone/ozone_export.h" namespace ui { namespace { // No...
8ae56b33-d651-4cfc-8bd1-83a5a57351f7
{ "language": "C++" }
```c++ #include <iostream> #include <gflags/gflags.h> DEFINE_string(message, "Hello World!", "The message to print"); int main(int argc, char **argv) { gflags::SetUsageMessage("Test CMake configuration of gflags library (gflags-config.cmake)"); gflags::ParseCommandLineFlags(&argc, &argv, true); std::cout << FLA...
```c++ #include <iostream> #include <gflags/gflags.h> DEFINE_string(message, "Hello World!", "The message to print"); static bool ValidateMessage(const char* flagname, const std::string &message) { return !message.empty(); } DEFINE_validator(message, ValidateMessage); int main(int argc, char **argv) { gflags::Se...
98e3918f-7347-422d-966e-be80e9bcc5d5
{ "language": "C++" }
```c++ ``` Add a test case for r216663 [-Zl vs LIBCMT vs asan_win_uar_thunk]
```c++ // Make sure LIBCMT doesn't accidentally get added to the list of DEFAULTLIB // directives. REQUIRES: asan-dynamic-runtime // RUN: %clang_cl_asan -LD %s | FileCheck %s // CHECK: Creating library // CHECK-NOT: LIBCMT void foo(int *p) { *p = 42; } __declspec(dllexport) void bar() { int x; foo(&x); } ```
400cf6e7-1960-49dd-9390-71fe15dc0622
{ "language": "C++" }
```c++ ``` Add solution for chapter 17 test 31, test 32
```c++ #include <iostream> #include <random> #include <string> using namespace std; bool play(bool first) { static default_random_engine e; static bernoulli_distribution b; return b(e); } int main() { string resp; static default_random_engine e; static bernoulli_distributio...
62fd3804-288a-4042-b7c3-e09e821701b6
{ "language": "C++" }
```c++ ``` Add Golden Section Search (Ternary Search)
```c++ double gss(double l, double r) { double m1 = r-(r-l)/gr, m2 = l+(r-l)/gr; double f1 = f(m1), f2 = f(m2); while(fabs(l-r)>EPS) { if(f1>f2) l=m1, f1=f2, m1=m2, m2=l+(r-l)/gr, f2=f(m2); else r=m2, f2=f1, m2=m1, m1=r-(r-l)/gr, f1=f(m1); } return l; } ```
38242cb4-6e5e-43f6-9d6f-7b72287c497c
{ "language": "C++" }
```c++ ``` Add file which defines test case
```c++ #include "path_aggregation_test.hpp" INSTANTIATE_TEST_CASE_P(PathAggregationTest, PathAggregationTest, testing::Combine( testing::Values(0, 1, 10), testing::Values(10, 20), testing::Values(120, 40) )); ```
09d38f37-b2c0-4b19-b56c-f00ecbbd0bc8
{ "language": "C++" }
```c++ ``` Add and Search Word - Data structure design
```c++ class Trie{ public: vector<Trie*> children; bool wholeWord; Trie(){ children = vector<Trie*>(26, NULL); wholeWord = false; } }; class WordDictionary { private: Trie* root; public: WordDictionary(){ root = new Trie(); } // Adds a word into the data structur...
00d05fef-97be-4d54-aae3-50379f03214b
{ "language": "C++" }
```c++ ``` Add unit test for Game to test mulligan process code
```c++ // Copyright (c) 2018 Chris Ohk, Youngjoong Kim, SeungHyun Jeon // We are making my contributions/submissions to this project solely in our // personal capacity and are not conveying any rights to any intellectual // property of any third parties. #include <Utils/TestUtils.hpp> #include "gtest/gtest.h" #inclu...
71058427-1410-4d59-b20a-9e76b41d2585
{ "language": "C++" }
```c++ ``` Add unit tests for ConstArray
```c++ /** * @file ConstArray_test.cpp * @brief Unit tests for the ConstArray class. * @author Dominique LaSalle <dominique@solidlake.com> * Copyright 2018 * @version 1 * @date 2018-11-14 */ #include "UnitTest.hpp" #include "ConstArray.hpp" #include "Array.hpp" #include <cstdlib> #include <vector> namespace sl { ...
38d25b59-bc0f-41d2-93e5-7a31da4d76c9
{ "language": "C++" }
```c++ ``` Add a new SkMemory implementation that uses mozalloc instead of malloc
```c++ /* * Copyright 2011 Google Inc. * Copyright 2012 Mozilla Foundation * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "SkTypes.h" #include "mozilla/mozalloc.h" #include "mozilla/mozalloc_abort.h" #include "mozilla/mozalloc_oom.h" void sk_...
aaee6a3b-d651-45e4-8df2-7491cece4a45
{ "language": "C++" }
```c++ ``` Add a test that presently fails.
```c++ //---------------------------- find_cell_1.cc --------------------------- // $Id$ // Version: $Name$ // // Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer // t...
efba4f85-038a-4bb8-aeba-0d34a49d89f3
{ "language": "C++" }
```c++ ``` Add an implementation of Maximum Weight Independent Subsequence in CPP
```c++ #include<iostream> #include<algorithm> using namespace std; int main() { int *W, *A, N; cin >> N; W = new int[N + 1]; A = new int[N + 1]; for (int i = 1; i < N + 1; i++) { cin >> W[i]; } A[0] = 0; A[1] = W[1]; for (int i = 2; i < N + 1; i++) { A[i] = max(A[i - 1], A[i - 2] + W[i])...
404e9742-0e11-4124-81f2-e97e2605e07a
{ "language": "C++" }
```c++ ``` Implement a simple two-dimension point generation procedure with regard to certain probability function, with the help of discrete_distribution
```c++ // two_dim_rand.cpp // #include <iostream> #include <boost/bind.hpp> #include <boost/lexical_cast.hpp> #include <boost/random.hpp> double on_circle_prob(double x, double y) { static const double k_delta = 0.01; if (std::abs(x*x + y*y - 1) <= k_delta) return 1.0; else return 0; } in...
676a42d4-c5c8-46e2-9236-490b2e8bdfe4
{ "language": "C++" }
```c++ ``` Add algorithm for Inverse FFT
```c++ /* * @author Abhishek Datta * @github_id abdatta * @since 15th October, 2017 * * The following algroithm takes complex coeeficients * and calculates its inverse discrete fourier transform */ #include <complex> #include <iostream> #include <iomanip> #include <valarray> const double PI = std::acos(-1); typede...
730587d3-5056-4acd-8c6d-248313a5125e
{ "language": "C++" }
```c++ ``` Add a solution for task 1b
```c++ #include <cstdio> #include <cmath> using namespace std; int a[1000010]; bool is_prime(int number) { if (number < 2) return false; double root = sqrt(number); for (int i = 2; i <= root; i++) { if (number % i == 0) return false; } return true; } int main() { for (int i = 1; i <= 1000000; i++...
bb59ab7f-188c-4994-a46e-c83ad6938724
{ "language": "C++" }
```c++ ``` Remove Duplicates from Sorted Array II
```c++ class Solution { public: int removeDuplicates(vector<int>& nums) { int index = 1; int cur_count = 1; int total = nums.size(); for (int i = 1; i < total; ++i) { if (nums[i] == nums[i-1]) { ++cur_count; if (cur_count <= 2) { ...
b27982d6-dd91-4f80-ae5e-08bea77ec8c7
{ "language": "C++" }
```c++ ``` Add a simple demo for sphere-plane intersection
```c++ #include "eigen.hh" #include "geometry/intersection/sphere_plane.hh" #include "geometry/rotation_to.hh" #include "geometry/shapes/circle.hh" #include "geometry/shapes/halfspace.hh" #include "geometry/shapes/sphere.hh" #include "viewer/primitives/simple_geometry.hh" #include "viewer/window_3d.hh" namespace geo...
c6c92c06-761f-4192-b2fc-96b2d837631d
{ "language": "C++" }
```c++ ``` Add "read line of integers" sample
```c++ // Read a line of integers into a container #include <vector> #include <sstream> #include <iterator> int main() { std::istringstream stream{"4 36 72 8"}; std::vector<int> values; std::copy(std::istream_iterator<int>{stream}, std::istream_iterator<int>{}, std::back_inserter(values)); }...
dce52191-1ed4-4701-b1bf-a45404f2f21f
{ "language": "C++" }
```c++ ``` Test for address of label operator.
```c++ // // Copyright 2013 Jeff Bush // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or a...
f22e4d7f-e972-4729-8d64-ca5680dc0fa0
{ "language": "C++" }
```c++ ``` Add file missed in r884: initial sketching of algorithm negotiation initialization.
```c++ #include <map> #include <common/buffer.h> #include <common/endian.h> #include <ssh/ssh_algorithm_negotiation.h> #include <ssh/ssh_protocol.h> namespace { static uint8_t constant_cookie[16] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0 }; templat...
adeb6416-00ef-455a-9d81-b7ce31785732
{ "language": "C++" }
```c++ ``` Add first test for XYZ format
```c++ #include "catch.hpp" #include "Harp.hpp" using namespace harp; #define XYZDIR SRCDIR "/files/xyz/" TEST_CASE("Read files in XYZ format", "[XYZ]"){ auto file = Trajectory(XYZDIR"helium.xyz"); Frame frame; SECTION("Stream style reading"){ file >> frame; CHECK(frame.natoms() == 125);...
6ef88e4a-ab00-4dc7-855d-ebefb4017660
{ "language": "C++" }
```c++ ``` Add Solution for 3. Longest Substring Without Repeating Characters
```c++ // 3. Longest Substring Without Repeating Characters /** * Given a string, find the length of the longest substring without repeating characters. * * Examples: * * Given "abcabcbb", the answer is "abc", which the length is 3. * * Given "bbbbb", the answer is "b", with the length of 1. * * Given "pww...
33c5614a-147a-4562-9f17-c1104a02f2b0
{ "language": "C++" }
```c++ ``` Add skeleton profileinfoloader pass. This will be enhanced to actually LOAD a profile tommorow. :)
```c++ //===- ProfileInfoLoaderPass.cpp - LLVM Pass to load profile info ---------===// // // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===-...
2318a6cb-7a36-4395-83d4-696cc7e5201b
{ "language": "C++" }
```c++ // Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/toolbar/test_toolbar_model.h" TestToolbarModel::TestToolbarModel() : ToolbarModel(), should_replace_url_(fal...
```c++ // Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/toolbar/test_toolbar_model.h" #include "grit/theme_resources.h" TestToolbarModel::TestToolbarModel() : ToolbarMod...
d9d087f5-e464-4581-a06f-d17d8b7789d1
{ "language": "C++" }
```c++ ``` Add the main() for google tests
```c++ /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) * Copyright (C) 2013, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * ...
9f90edee-77aa-42f4-8360-88416c608022
{ "language": "C++" }
```c++ ``` Solve problem 25 in C++
```c++ // Copyright 2016 Mitchell Kember. Subject to the MIT License. // Project Euler: Problem 25 // 1000-digit Fibonacci number #include <gmpxx.h> namespace problem_25 { long solve() { mpz_class first(1); mpz_class second(1); mpz_class power_of_ten(10); mpz_class* a = &first; mpz_class* b = &second; long in...
deab6509-d44c-4403-ad50-893fdbb8f01b
{ "language": "C++" }
```c++ ``` Add solution for chapter 16 test 34
```c++ #include <iostream> #include <string> using namespace std; template <typename T> int compare(const T &l , const T &r) {//remove the &, then works. if(l > r) return 1; if(r > l) return -1; return 0; } int main() { // cout << compare("hi", "world"); cout << compare("bye", "dad")...
a0a7a560-53b9-4a07-be7a-40a7c1b03257
{ "language": "C++" }
```c++ ``` Add a test for ExternalCode functionality.
```c++ #include <stdio.h> #include "Halide.h" #include <fstream> #include <cassert> #include <iostream> #include "test/common/halide_test_dirs.h" using namespace Halide; int main(int argc, char **argv) { Var x("x"), y("y"); Func f("f"); f(x, y) = 42; std::string bitcode_file = Internal::get_test_tm...
064057cb-1b4e-47ee-af72-acbebef098f4
{ "language": "C++" }
```c++ ``` Add linked list based solution
```c++ #include <cassert> #include <iostream> #include <vector> using namespace std; const int MAX_N = 100; // We will put the regions in a circular doubly linked list. struct Region { int id; Region *prev, *next; }; int main() { while (true) { int N; cin >> N; if (N == 0) break; // Al...
731d9607-c68c-4d15-8447-8370f7be8c06
{ "language": "C++" }
```c++ ``` Swap Adjacent in LR String
```c++ class Solution { public: bool canTransform(string start, string end) { int i = 0, j = 0, n = start.length(); while(j < n && i < n){ while(j < n && end[j] == 'X') j++; while(i < n && start[i] == 'X') i++l if(i == n && j == n) break; if(i == n ||...
51f5fc56-3036-4b1b-b76b-d8a63acf4b0d
{ "language": "C++" }
```c++ ``` Add unit test for inverse_spd.
```c++ #include <stan/math/matrix/inverse_spd.hpp> #include <stan/math/matrix/multiply.hpp> #include <gtest/gtest.h> #include <test/agrad/util.hpp> #include <stan/agrad/agrad.hpp> #include <stan/agrad/matrix.hpp> #include <stan/agrad/rev/print_stack.hpp> TEST(AgradRevMatrix,inverse_spd_val) { using stan::math::inver...
f0cf467a-6930-410d-aa08-28079a3515b1
{ "language": "C++" }
```c++ ``` Add extra testing for init-captures.
```c++ // RUN: %clang_cc1 -std=c++1y %s -verify // expected-no-diagnostics namespace variadic_expansion { void f(int &, char &); template <typename ... T> void g(T &... t) { f([&a(t)]()->decltype(auto) { return a; }() ...); } void h(int i, char c) { g(i, c); } } ```
f63e15a0-1160-41fb-a8e4-1472c54cd417
{ "language": "C++" }
```c++ ``` Add a crazy test case for r243987
```c++ // RUN: %clang_cc1 -fsyntax-only -verify %s // This is not well-formed C++ but used to crash in sema. template <class T> struct X { template <class U> struct A { // expected-note {{not-yet-instantiated member is declared here}} template <class V> struct B { template <class W> struct C {...
558f3fa1-6538-4575-a30d-8ef1d33fc5d4
{ "language": "C++" }
```c++ ``` Add tests for hook class
```c++ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ #include "catch.hpp" #include "hooks.hh" static int i; void inc_i(vick::contents&) { ++i; } TEST_CASE("hook proc", "[hook]") { vick::hook h; vick::contents c; h.add(inc_i); int li = i; ...
3b963de2-4d8a-4f48-bcab-2dc55dc578c7
{ "language": "C++" }
```c++ #include "mock_player.hpp" #include <ctime> #include <boost/random/discrete_distribution.hpp> #include "logger.hpp" #include "walk_move.hpp" #include "wall_move.hpp" #include "exception.hpp" static boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg; namespace Quoridor { MockPlayer...
```c++ #include "mock_player.hpp" #include <ctime> #include <boost/random/discrete_distribution.hpp> #include "logger.hpp" #include "walk_move.hpp" #include "wall_move.hpp" #include "exception.hpp" static boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg; namespace Quoridor { MockPlayer...
4b59d633-a5e1-42e2-a126-d57124304551
{ "language": "C++" }
```c++ ``` Add C++ solution to the interger-length problem.
```c++ #include <iostream> //Function to calculate number of integers in a given number. int integer_length(long long int n){ int length = 0; while (n!=0){ length++; n=n/10; } return length; } //Driver function. int main(){ std::cout << integer_length(34) << std::endl; std::cou...
87b42aad-7685-48ff-96cb-fa8c25307ca6
{ "language": "C++" }
```c++ ``` Add Solution for Problem 017
```c++ // 17. Letter Combinations of a Phone Number /** * Given a digit string, return all possible letter combinations that the number could represent. * * A mapping of digit to letters (just like on the telephone buttons) is given below. * * 1() 2(abc) 3(def) * 4(ghi) 5(jkl) 6(mno) * 7(pqrs) 8(tuv) 9...
9950a2de-df16-4b30-86bd-d5167756c834
{ "language": "C++" }
```c++ ``` Add examples on the use of class range
```c++ #include <iostream> #include <iterator> #include <vector> #include <list> #include <algorithm> #include "../utility.h" #include "../random.h" template<typename IteratorT> void print(const range<IteratorT>& r) { for (auto x : r) std::cout << x << " "; std::cout << std::endl; } template<typename...
d9b7d34a-51fb-4b5b-a218-e701fe9b8b40
{ "language": "C++" }
```c++ ``` Add Chapter 24, Try This 1
```c++ // Chapter 23, Try This 1: replace 333 in example with 10 #include<iostream> #include<iomanip> int main() { float x = 1.0/10; float sum = 0; for (int i = 0; i<10; ++i) sum += x; std::cout << std::setprecision(15) << sum << '\n'; }```
aa8ae3c1-13e6-47df-9b17-3a98d08eaa3c
{ "language": "C++" }
```c++ ``` Add push block with invalid transaction test
```c++ /** * @file * @copyright defined in eos/LICENSE.txt */ #include <boost/test/unit_test.hpp> #include <eosio/testing/tester.hpp> using namespace eosio; using namespace testing; using namespace chain; BOOST_AUTO_TEST_SUITE(block_tests) BOOST_AUTO_TEST_CASE(block_with_invalid_tx_test) { tester main; ...
ec909bce-f27c-43a6-bfe6-948a68dba6d1
{ "language": "C++" }
```c++ ``` Add the source file with trivial definitions in it that was missing from r151822, sorry sorry. =[
```c++ //===-------------- lib/Support/Hashing.cpp -------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===------------------------------------------------...
ccb8b6da-baff-45b1-bf22-c1457cceea3a
{ "language": "C++" }
```c++ ``` Add a test case that would have caught the bug fixed in r126640.
```c++ // RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT // DEFAULT: "-cc1" {{.*}} "-fcxx-exceptions" "-fexceptions" // // RUN: %clang -### -fexceptions %s 2>&1 | FileCheck %s -check-prefix=ON1 // ON1: "-cc1" {{.*}} "-fcxx-exceptions" "-fexceptions" // // RUN: %clang -### -fno-exceptions -fcxx-exceptions...
ae5c89c0-5264-40ab-8ee9-e58327c39fdb
{ "language": "C++" }
```c++ ``` Add Levy flight example back; updated to use al::RingBuffer
```c++ /* Allocore Example: Lévy flight Description: A Lévy flight is a random walk where the step size is determined by a function that is heavy-tailed. This example uses a Cauchy distribution. Author: Lance Putnam, 9/2011 */ #include "allocore/io/al_App.hpp" using namespace al; class MyApp : public App{ public: ...
d7657fd3-ddfa-4a31-9ab9-0afd73391241
{ "language": "C++" }
```c++ ``` Add file to demonstrate use of function pointer.
```c++ #include <iostream> #include <cmath> using namespace std; double integrate(double (*f)(double x), double a, double b) { int N = 10; double h = (b-a)/N; double integral = 0.0; for(int i=0; i<N; i++) { double x = a + (i+0.5)*h; integral += (*f)(x)*h; } return integral; } int main() { cout << integ...
22464c50-6dd8-4208-8867-f53ff573f5ae
{ "language": "C++" }
```c++ ``` Test for kmeans coordinator added
```c++ /** * Copyright 2014 Open Connectome Project (http://openconnecto.me) * Written by Disa Mhembere (disa) * * This file is part of FlashGraph. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of th...
60817889-b1d2-4025-91be-a1cd80e9baf8
{ "language": "C++" }
```c++ ``` Add a test for message passing.
```c++ // Test if message passing works // Should on x86, not on arm // Basically always just doesn't see the write at all. // Probably need to loop. #include <atomic> #include <stdio.h> // Note that writing the test in C++ is kind of bogus, since // the *compiler* can reorder. std::atomic<long> data = {0}; std::atom...
46773afe-ba1e-42f9-97b4-1dec36c6ade2
{ "language": "C++" }
```c++ ``` Add tests showing we discard all-default messages
```c++ /// \file stream.cpp /// /// Unit tests for stream functions #include "../stream.hpp" #include "vg.pb.h" #include "catch.hpp" #include <sstream> #include <iostream> namespace vg { namespace unittest { using namespace std; TEST_CASE("Protobuf messages that are all default can be stored and retrieved", "[s...
c2753a10-5bb8-440b-add7-8052708cad1b
{ "language": "C++" }
```c++ ``` Add a test for diagnose_if.
```c++ // RUN: %clang_cc1 -Wpedantic -fsyntax-only %s -verify void foo() __attribute__((diagnose_if(1, "", "error"))); // expected-warning{{'diagnose_if' is a clang extension}} void foo(int a) __attribute__((diagnose_if(a, "", "error"))); // expected-warning{{'diagnose_if' is a clang extension}} // FIXME: When diagnos...
e864fb88-535f-4738-81dc-161f552bf264
{ "language": "C++" }
```c++ ``` Add macro to compare old and new propagation methods
```c++ #include <ctime> #include <iostream> #include "PremModel.h" #include "PMNS_Fast.h" using namespace std; int main(int argc, char **argv){ int minM = 0; int maxM = 2; if(argc>1){ string test = argv[1]; if(test=="new") maxM = 1; if(test=="old") minM = 1; } int ntries = 1e4; if(maxM-mi...
15133fce-dfec-44c7-a48a-8a60bdd60a34
{ "language": "C++" }
```c++ ``` Add the test case from PR 14044 to ensure it doesn't regress.
```c++ // RUN: %clang_cc1 -verify -chain-include %s %s // PR 14044 #ifndef PASS1 #define PASS1 class S { void f(struct Test); }; #else ::Tesy *p; // expected-error {{did you mean 'Test'}} // expected-note@-4 {{'Test' declared here}} #endif ```
ab92badd-14a2-4742-ae8e-799ee479f139
{ "language": "C++" }
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromeos/dbus/ibus/mock_ibus_engine_service.h" namespace chromeos { MockIBusEngineService::MockIBusEngineService() { } MockIBusEng...
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromeos/dbus/ibus/mock_ibus_engine_service.h" namespace chromeos { MockIBusEngineService::MockIBusEngineService() { } MockIBusEng...
dbcf6dcb-f3ae-42cc-afd6-e46244c3aa39
{ "language": "C++" }
```c++ ``` Add central limiting theorem method
```c++ #include "test.h" #include "lcg.h" // By central limiting theorem, // U ~ [0, 1] // S = sum U_i for i = 1 to M // S ~ N(M / 2, M / 12) // Z = (S - M / 2) / sqrt(M / 12) // Z ~ N(0, 1) template <class T, class RNG, int M> static inline T clt(RNG& r) { static T inv = 1 / std::sqrt(T(M) / 12); T sum = 0; for ...
57d40e8b-513b-450d-97bc-a7d3f0fc5564
{ "language": "C++" }
```c++ ``` Add c++ fatorial template meta programming example
```c++ #include <iostream> template <int N> int fat() { return N * fat<N-1>(); } template <> int fat<1>() { return 1; } int main() { const int fat5 = fat<5>(); std::cout << fat5 << std::endl; } ```
c9e5be72-4d74-456e-a348-a32f004f5a9e
{ "language": "C++" }
```c++ ``` Prepare test case for performance test of SGD
```c++ //======================================================================= // Copyright (c) 2014-2016 Baptiste Wicht // Distributed under the terms of the MIT License. // (See accompanying file LICENSE or copy at // http://opensource.org/licenses/MIT) //===========================================================...
e22093f6-40df-4e70-8e57-b8837f6b5be9
{ "language": "C++" }
```c++ ``` Edit distance, classic problem, need to recheck
```c++ #include <iostream> #include <string> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <algorithm> #include <functional> #include <utility> #include <cstdio> #include <cstdlib> using namespace std; // dist[i][j] = the di...
656bb157-da63-4532-8709-0b0e14e54476
{ "language": "C++" }
```c++ // Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/base/win/dpi_setup.h" #include "ui/base/layout.h" #include "ui/gfx/display.h" #include "ui/gfx/win/dpi.h" namespace ui { namespa...
```c++ // Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/base/win/dpi_setup.h" #include "ui/base/layout.h" #include "ui/gfx/display.h" #include "ui/gfx/win/dpi.h" namespace ui { namespa...
c7f93784-d503-452b-b8a2-6d80c2b2cad6
{ "language": "C++" }
```c++ ``` Add test for OSS-Fuzz 813
```c++ /* * (C) 2017 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #include "tests.h" #if defined(BOTAN_HAS_ASN1) #include <botan/der_enc.h> #include <botan/ber_dec.h> #endif namespace Botan_Tests { #if defined(BOTAN_HAS_ASN1) namespace { Test::Result test_ber_stack_...
198779ff-8f14-40b5-af61-6cdb9452160c
{ "language": "C++" }
```c++ ``` Add some code to output the bit patterns for various ways of generating NaN and Inf, compile with -lm
```c++ #include <stdio.h> #include <math.h> #include <string> #include <sstream> template <class T> T from_str(const std::string & str){ std::istringstream sin(str); T ret; sin >> ret; return ret; } void print(double a){ printf("%.20f, %llX\n", a, *((unsigned long long *) &a)); } int main(int argc, char **argv...
ef6272bd-549d-419a-b0a8-5243a8785d53
{ "language": "C++" }
```c++ ``` Add unit tests to assign operation
```c++ #include <catch.hpp> #include "Chip8.hpp" #include "CPU.hpp" namespace { using namespace Core8; SCENARIO("CPUs can assign the value of one register to another", "[assign]") { GIVEN("A CPU with some initialized registers") { CPU cpu{}; cpu.writeRegister(Chip8::REGISTER::V0, 0x01); cpu.writeRegis...
df73e2ce-eaca-4b96-8d22-ecd5f3ecbcc3
{ "language": "C++" }
```c++ ``` Add stub for unit-testing the color conversion.
```c++ // ========================================================================== // // This file is part of DO++, a basic set of libraries in C++ for computer // vision. // // Copyright (C) 2014 David Ok <david.ok8@gmail.com> // // This Source Code Form is subject to the terms of the Mozilla Public // License v. ...