doc_id
stringlengths
36
36
metadata
dict
input
stringlengths
28
4.3k
output
stringlengths
11
5.45k
ef8ccc3d-9d13-41f8-9a39-03330d057868
{ "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 "build/build_config.h" #include "chrome/browser/first_run/upgrade_util.h" // The entry point for all invocations of Chromium, browser...
```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 "build/build_config.h" #include "chrome/browser/first_run/upgrade_util.h" // The entry point for all invocations of Chromium, browser...
d261aabb-fc8a-4aa8-b617-025694a69330
{ "language": "C++" }
```c++ ``` Add example to read tracks from binary output file
```c++ #include <stdio.h> #include <stdlib.h> #include <vector> #include "outputtrack.h" int main(int argc, char** argv) { FILE* fpInput = fopen("../output.bin", "rb"); if (fpInput == NULL) { printf("Error opening input file\n"); exit(1); } //Loop over all events in the input file. //Number of events is no...
4d1507c7-4289-47e4-8a71-ee266cc00ed9
{ "language": "C++" }
```c++ ``` Add a test for the -c flag.
```c++ // Test that the -c flag works. // RUN: llvmc -c %s -o %t.o // RUN: llvmc --linker=c++ %t.o -o %t // RUN: %abs_tmp | grep hello // XFAIL: vg #include <iostream> int main() { std::cout << "hello" << '\n'; } ```
1473b10d-3939-4a02-bd36-4a817a179095
{ "language": "C++" }
```c++ ``` Add Solution for 019 Remove Nth Node From End of List
```c++ // 19. Remove Nth Node From End of List /** * Given a linked list, remove the nth node from the end of list and return its head. * * For example, * * Given linked list: 1->2->3->4->5, and n = 2. * * After removing the second node from the end, the linked list becomes 1->2->3->5. * * Note: * Given n...
6c3b1289-80d4-4c75-9f66-bd1011cdae24
{ "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 "ui/base/touch/touch_device.h" #include "base/win/windows_version.h" #include <windows.h> namespace ui { bool IsTouchDevicePresent()...
```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 "ui/base/touch/touch_device.h" #include "base/win/windows_version.h" #include <windows.h> namespace ui { bool IsTouchDevicePresent()...
91798410-a498-4506-b419-6933ff79cd82
{ "language": "C++" }
```c++ ``` Delete Node in a BST
```c++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : va...
a1965b57-f1e0-442b-91ce-a6548edbddab
{ "language": "C++" }
```c++ ``` Insert into a Binary Search Tree
```c++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : va...
efbcdc86-43e8-4d47-b097-a05ec021c477
{ "language": "C++" }
```c++ ``` Add a solution for task 9a
```c++ #include <cstdio> using namespace std; const int N = 1 << 10; int a[N][N], m; int INF = 1 << 20; int n = 0; void input() { for (int i = 0; i < m; i++) { int u, v, d; scanf("%d%d%d", &u, &v, &d); a[u][v] = d; if (u > n) n = u; if (v > n) n = v; } } void floyd() { for (int i = 1; i ...
59e8c75e-9596-4595-a9ab-5349b0ef44a3
{ "language": "C++" }
```c++ ``` Add an example C++ code from real life
```c++ //kinda-sorta functional code from Real Life (tm): // The operator<() will sort this vector by version in descending order, // placing pure AutoCAD first in respective sequence of matching versions. std::sort (values.begin (), values.end ()); // The operator==() will eliminate adjacent elements with matching v...
d961cb23-c9d5-4aad-b1c6-1b547e5dc42e
{ "language": "C++" }
```c++ ``` Add test during development for parser.
```c++ #include "HSHumanoidNodeParser.hpp" namespace dynamicsJRLJapan { namespace HumanoidSpecificitiesData { namespace fusion = boost::fusion; namespace phoenix = boost::phoenix; namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; int ReadXMLData3(std::string...
68769758-2b1a-4b34-ad1c-68d9aa689a6e
{ "language": "C++" }
```c++ ``` Add the solution to "Angry Children".
```c++ #include <iostream> #include <algorithm> #include <vector> using namespace std; int unfairness(vector<int> &a, int k) { sort(a.begin(), a.end()); int unfairness = a[k - 1] - a[0]; for (int i = 1; i <= a.size() - k; i++) { if (a[i + k - 1] - a[i] < unfairness) { unfairness = a[i + k - 1] - a[i]; } } ...
207581e6-9495-44fb-9d74-9c9fe418c1f1
{ "language": "C++" }
```c++ ``` Add missing file from r300155.
```c++ //===--------------- RPCUtils.cpp - RPCUtils implementation ---------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===------------------------------------------------...
dd4b472e-e5c8-452d-bfe0-5f9620e296e7
{ "language": "C++" }
```c++ ``` Add the solution to determine whether there's a cycle in a linked list.
```c++ #include<iostream> #include<cstdio> #include<cstdlib> using namespace std; struct Node { int data; Node* next; }; int HasCycle(Node* head) { Node* slow = head; Node* fast = head; while (fast != NULL && fast->next != NULL) { slow = slow->next; fast = fast->next->next; if (slo...
cdbad5b1-11c0-46c2-be2a-39bb84b093d8
{ "language": "C++" }
```c++ ``` Write the main structure of the algorithm
```c++ // // main.c // SequentialSA // // Created by Vincent Ramdhanie on 11/27/14. // Copyright (c) 2014 Vincent Ramdhanie. All rights reserved. // #include <time.h> #include <iostream> #include <fstream> #include <iostream> #include "generator.h" #include "generator.cpp" int cost(); //cost function calculates t...
11ce8b05-b70f-4429-b50e-97d178496987
{ "language": "C++" }
```c++ ``` Add solution to week 11 Shapes problem
```c++ #include <iostream> #include <cmath> using std::cout; using std::cin; class Shape { public: virtual double perimeter() const = 0; virtual double area() const = 0; virtual void print() const = 0; }; class Rectangle: public Shape { protected: double a; double b; public: Rectangle(double _a, doubl...
6d8bdfcd-387f-47c2-b014-67e3d6533a30
{ "language": "C++" }
```c++ ``` Add the solution to "Subtle Summation".
```c++ #include <iostream> #include <algorithm> using namespace std; bool zero(int *a, int n) { int *b = new int[n]; b[0] = a[0]; if (a[0] == 0) { return true; } for (int i = 1; i < n; i++) { b[i] = b[i - 1] + a[i]; } sort(b, b + n); for (int i = 1; i < n; i++) { if (b[0] == 0) { return true; } i...
71a90a4f-1574-4e3d-9f56-cee8fc03570c
{ "language": "C++" }
```c++ ``` Add (failing) test that halide reports user error when called with OpenGL in bad state
```c++ #include <csetjmp> #include <unistd.h> #if defined(__APPLE__) #include <OpenGL/gl.h> #else #include <GL/gl.h> #endif #include "Halide.h" #include "HalideRuntimeOpenGL.h" std::string error_message; /* ** Don't rely on func.set_error_handler() mechanism, it doesn't seem to catch ** the user OpenGL state errors...
fec52f3f-f193-463c-8ce8-d23284f7f201
{ "language": "C++" }
```c++ ``` Add tests for dirty propagation
```c++ /** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ #in...
32bd52a0-9c11-4574-b177-058378a20890
{ "language": "C++" }
```c++ ``` Add Chapter 25, exercise 11
```c++ // Chapter 25, exercise 11: like exercise 10, but keep the bits in a bitset<32> #include<iostream> #include<bitset> using namespace std; int main() { bitset<32> bs; bs = 15121<<10; // PFN bs |= 6<<4; // CCA bs[3] = 1; // nonreachable bs[0] = 1; // global cout << "Usin...
d4b4f389-6518-4423-8fa1-0f7cabe6de5b
{ "language": "C++" }
```c++ ``` Add a small test case
```c++ #include "gfakluge.hpp" int main() { gfak::GFAKluge og; og.set_version(1); gfak::sequence_elem s; s.sequence = "ACCTT"; s.name = "11"; gfak::sequence_elem t; t.sequence = "TCAAGG"; t.name = "12"; gfak::sequence_elem u; u.sequence = "CTTGATT"; u.name = "13"; g...
b1a231e5-f3fd-4c9f-98d9-74e0c10a90fb
{ "language": "C++" }
```c++ ``` Test harness for the new TimeUtil::GetJulianDayNumber() function.
```c++ #include <iomanip> #include <iostream> #include "TimeUtil.h" int main() { std::cout << std::setprecision(10) << TimeUtil::GetJulianDayNumber() << '\n'; return 0; } ```
c4d7216b-81c3-4aad-89b7-01019ae304c1
{ "language": "C++" }
```c++ ``` Add a solution for problem 164: Maximum Gap.
```c++ // Naive solution would first sort the numbers, then find the maximum gap. // But there is a better solution: use the pigeonhole principle. // Suppose the sorted sequence of arguments are a1, a2, ..., an. // There are n-1 gaps and the accumulated gap is an-a1. The average gap is // (an-a1)/(n-1). By the pigeonho...
cc9111a6-f911-4165-9e51-e7651c73ae6a
{ "language": "C++" }
```c++ ``` Add some basic unit tests for the value functors.
```c++ /** \file * * Copyright (c) 2015 by Travis Gockel. All rights reserved. * * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later * ...
fe7239a2-774b-4a89-8837-3d12d09e68bf
{ "language": "C++" }
```c++ ``` Add solution for chapter 17 test 11, 12, 13
```c++ #include <iostream> #include <bitset> #include <vector> using namespace std; template <unsigned N> class TestResult { template <unsigned M> friend ostream& operator<<(ostream&, TestResult<M>&); public: TestResult() = default; TestResult(unsigned long long u) : ans(u) { } Test...
5e32f9b7-d913-456a-b0e9-f8bc2f6b5977
{ "language": "C++" }
```c++ #include "IncomingConnectionValidator.hpp" #include <boost/algorithm/string.hpp> using namespace std; sip::IncomingConnectionValidator::IncomingConnectionValidator(std::string validUriExpression) : validUriExpression(validUriExpression), logger(log4cpp::Category::getInstance("IncomingConnect...
```c++ #include "IncomingConnectionValidator.hpp" #include <boost/algorithm/string.hpp> using namespace std; sip::IncomingConnectionValidator::IncomingConnectionValidator(std::string validUriExpression) : validUriExpression(validUriExpression), logger(log4cpp::Category::getInstance("IncomingConnect...
83ef3b59-9144-4061-9b8e-4c91131b7c32
{ "language": "C++" }
```c++ ``` Add algorithm to check if a number belong to fibo series.
```c++ #include <bits/stdc++.h> using namespace std; bool isPerfectSquare(int x){ int s = sqrt(x); return (s*s == x); } bool isFibonacci(int n){ // n is Fibinacci if one of 5*n*n + 4 or 5*n*n - 4 or both // is a perferct square, this is deduced of the discriminant //of binnets formule return isPerfe...
8d44d871-ce46-4643-8363-b181dfd59dc9
{ "language": "C++" }
```c++ ``` Clean up C++ restrict test cases and add a test for restrict qualified methods.
```c++ // RUN: %llvmgxx -c -emit-llvm %s -o - | llvm-dis | grep noalias class foo { int member[4]; void bar(int * a); }; void foo::bar(int * a) __restrict { member[3] = *a; } ```
35b12edb-ef79-4abf-8c39-b8ee989142ab
{ "language": "C++" }
```c++ ``` Add Solution for 066 Plus One
```c++ // 66. Plus One /** * Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. * * You may assume the integer do not contain any leading zero, except the number 0 itself. * * The digits are stored such that the most significant digit is at the head of the list. * ...
ad12aeb6-04ec-4511-80db-0cd52f6d84da
{ "language": "C++" }
```c++ ``` Add solution for chapter 18, test 22
```c++ #include <iostream> using namespace std; class A { public: A() { cout << "A()" << endl; } }; class B : public A { public: B() { cout << "B()" << endl; } }; class C : public B { public: C() { cout << "C()" << endl; } }; class X { publi...
dcd0045f-9d5c-4f73-bd5e-39ff55ee8aef
{ "language": "C++" }
```c++ ``` Add a testcase for C++11 union support.
```c++ // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s union E { int a; float b; int bb() { return a;} float aa() { return b;} E() { a = 0; } }; E e; // CHECK: metadata !{i32 {{.*}}, null, metadata !"E", metadata !6, i32 3, i64 32, i64 32, i64 0, i32 0, null, ...
56a96587-f5fd-42e7-9792-4d0687bb88f8
{ "language": "C++" }
```c++ ``` Add solution to second homework
```c++ #include <vector> #include <queue> #include <unordered_set> #include <iostream> using namespace std; void bfs(int S, const vector<vector<int>>& adjLists, vector<int>& results) { queue<int> toTraverse; toTraverse.push(S); unordered_set<int> traversed; traversed.emplace(S); while (!toTraverse.empty())...
4a7efd77-0b0e-4f05-972c-6bc1935ab748
{ "language": "C++" }
```c++ ``` Add initial opto model tests
```c++ // // TestOptocoupler.cpp // FxDSP // // Created by Hamilton Kibbe on 5/3/15. // Copyright (c) 2015 Hamilton Kibbe. All rights reserved. // #include "Optocoupler.h" #include <math.h> #include <gtest/gtest.h> TEST(OptocouplerSingle, Smoketest) { const Opto_t types[2] = {OPTO_LDR, OPTO_PHOTOTRANSISTOR}...
426da2f4-21cd-4d43-a243-2f75af4b8338
{ "language": "C++" }
```c++ #include "usbutil.h" USBDevice USB_DEVICE(usbCallback); USB_HANDLE USB_INPUT_HANDLE = 0; void send_message(uint8_t* message, int message_size) { int currentByte = 0; Serial.print("sending message: "); Serial.println((char*)message); while(currentByte <= message_size) { while(USB_DEVICE...
```c++ #include "usbutil.h" USBDevice USB_DEVICE(usbCallback); USB_HANDLE USB_INPUT_HANDLE = 0; void send_message(uint8_t* message, int message_size) { int nextByteIndex = 0; Serial.print("sending message: "); Serial.println((char*)message); while(nextByteIndex < message_size) { while(USB_DEV...
d63826b3-239a-4851-93e9-b43a37c3d9e4
{ "language": "C++" }
```c++ ``` Enable to build empty components for Windows.
```c++ #ifdef _WINDOWS /* * NOTE: Some macros must be defined in project options of Visual Studio. * - NOMINMAX * To use std::min(), std::max(). * NOTE: Suppress some warnings of Visual Studio. * - C4251 */ #include <windows.h> BOOL APIENTRY DllMain( HMODULE hModule, ...
56bc9e45-2a1e-48eb-b14f-c158f39d76f0
{ "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/aura/window_observer.h" #include "base/logging.h" #include "ui/aura/window.h" namespace aura { WindowObserver::WindowObserver() : o...
```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/aura/window_observer.h" #include "base/logging.h" #include "ui/aura/window.h" namespace aura { WindowObserver::WindowObserver() : o...
1b2f0a8d-baa0-41d5-873b-e920968045bd
{ "language": "C++" }
```c++ ``` Add unit test for HypreParVector::Read
```c++ // Copyright (c) 2010-2021, Lawrence Livermore National Security, LLC. Produced // at the Lawrence Livermore National Laboratory. All Rights reserved. See files // LICENSE and NOTICE for details. LLNL-CODE-806117. // // This file is part of the MFEM library. For more information and source code // availability v...
cf16faa7-1ef9-40f8-8d36-a13f7635ab64
{ "language": "C++" }
```c++ ``` Add Solution for Problem 143
```c++ // 143_Reorder_List.cpp : Defines the entry point for the console application. /** * Given a singly linked list L: L0->L1->->Ln-1->Ln, * reorder it to: L0->Ln->L1->Ln-1->L2->Ln-2-> * * You must do this in-place without altering the nodes' values. * * For example, * Given {1,2,3,4}, reorder it to {1,4,2,3}...
c6a4df0e-c244-4fc4-a4e2-a2fbba419935
{ "language": "C++" }
```c++ ``` Add solution to problem 3.
```c++ /* * Largest prime factor * * The prime factors of 13'195 are 5, 7, 13 and 29. * * What is the largest prime factor of the number 600'851'475'143? */ #include <algorithm> #include <cmath> #include <cstddef> #include <iostream> #include <vector> #include "sieve.hpp" constexpr Long number = 600'851'475'14...
3518f230-d7f8-486d-a70d-0c172a230dee
{ "language": "C++" }
```c++ ``` Add serialization of minimal template unit-test that is broken
```c++ /* Copyright (c) 2014, Randolph Voorhies, Shane Grant All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice,...
cd1361eb-3e93-4de7-855b-e8eb83dd29e2
{ "language": "C++" }
```c++ ``` Test harness for the new SimpleXMLParser class.
```c++ /** \brief Test harness for the SimpleXmlParser class. * \author Dr. Johannes Ruscheinski (johannes.ruscheinski@uni-tuebingen.de) * * \copyright 2015 Universitätsbiblothek Tübingen. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of th...
f597680d-a737-4b02-b9f2-5e1057bfcb04
{ "language": "C++" }
```c++ ``` Add a program to take an encrypted text string, shift it by the input key, and print the decrypted string.
```c++ /***************************************************************************** * File: keyShiftCypher.cpp * * Description: Take an encrypted text string, shift it by the input key, and * print the decrypted string. * * Author: Tim Troxler * * Created: 1/5/2015 * *****************...
7199aa10-0329-46b8-87e5-da278cec43ac
{ "language": "C++" }
```c++ ``` Test cereal for a basic save and load operation
```c++ #include "UnitTest++/UnitTest++.h" #include <fstream> #include <cereal/archives/binary.hpp> SUITE( CerealTest ) { TEST( basicSaveAndLoad ) { const std::string saveFileName = "CerealTest"; const int expectedData = 42; int actualData = 666; { std::ofstream fil...
25ddb42c-575a-46c4-aa9a-9d3681a0b4a3
{ "language": "C++" }
```c++ ``` Add Solution for 203 Remove Linked List Elements
```c++ // 203. Remove Linked List Elements /** * Remove all elements from a linked list of integers that have value val. * * Example * Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6 * Return: 1 --> 2 --> 3 --> 4 --> 5 * * Tags: Linked List * * Similar Problems: (E) Remove Element (E) Delete Node in a...
57daebe0-1913-4e25-bf2e-ce9c2d34be7a
{ "language": "C++" }
```c++ ``` Add solution to the power problem
```c++ #include <iostream> using namespace std; int powLastFourDigits(int number, long long unsigned power) { number %= 10000; if (power == 0) return 1; return (powLastFourDigits(number, power - 1) * number) % 10000; } int powIterLastFourDigits(int number, long long unsigned power) { int res...
bc168f6a-0a49-4ca1-b3a0-efa5eafc4992
{ "language": "C++" }
```c++ ``` Advance Program for Binary Search
```c++ // To find an element in increasing seq. of values #include <bits/stdc++.h> using namespace std; int arr[100]; int binary(int l,int r,int key) // Code template for Binary Search { while(l<=r) { int mid = (l+r)/2; if(arr[mid] == key) // key is the element to find { return mid; } else if( arr[mi...
7038b103-ca44-4c21-a853-5eccc30b9585
{ "language": "C++" }
```c++ ``` Reduce Array Size to The Half
```c++ class Solution { public: int minSetSize(vector<int>& arr) { std::unordered_map<int, int> m; for (const auto& num : arr) { auto iter = m.find(num); if (iter == m.end()) { m[num] = 1; } else { ++m[num]; } } ...
de3b61a2-f997-4c4e-ba83-d34fc875b45c
{ "language": "C++" }
```c++ ``` Add a test for a crash with unnamed NamedDecls
```c++ // Makes sure it doesn't crash. // XFAIL: linux // RUN: rm -rf %t // RUN: not %clang_cc1 %s -index-store-path %t/idx -std=c++14 // RUN: c-index-test core -print-record %t/idx | FileCheck %s namespace rdar32474406 { void foo(); typedef void (*Func_t)(); // CHECK: [[@LINE+4]]:1 | type-alias/C | c:record-hash-cr...
3ce5ffb9-823b-4326-9d69-af1a236c4c1b
{ "language": "C++" }
```c++ ``` Add problem: Flipping the matrix
```c++ #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; // Enunciado: https://www.hackerrank.com/challenges/flipping-the-matrix int main() { unsigned q, n; cin >> q; for (int cq = 0; cq < q; ++cq) { cin >> n; // Cada eleme...
1ba5416a-2db9-4535-bfb0-c1477dd6aa04
{ "language": "C++" }
```c++ ``` Add a unit test for serialization
```c++ #include <memory> #include <string> #include <SFCGAL/all.h> #include <SFCGAL/Kernel.h> #include <SFCGAL/io/Serialization.h> #include <boost/test/unit_test.hpp> using namespace boost::unit_test ; using namespace SFCGAL ; BOOST_AUTO_TEST_SUITE( SFCGAL_io_WktReaderTest ) BOOST_AUTO_TEST_CASE( textTest ) { Ker...
3ef55db7-8695-4b57-b217-80203bc7cd46
{ "language": "C++" }
```c++ ``` Update to latest perforce change Change 21906 by waneck@wnk-razer on 2018/07/20 09:33:21
```c++ #include "HaxeRuntime.h" #include "VariantPtr.h" #include "CoreMinimal.h" #include "HaxeInit.h" void unreal::VariantPtr::badAlignmentAssert(UIntPtr value) { UE_LOG(HaxeLog, Fatal, TEXT("The pointer %llx was not aligned and is not supported by Unreal.hx"), value); }```
f5499ab1-78a0-43ac-b4b8-e5999ad438c0
{ "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 "mojo/common/user_agent.h" namespace mojo { namespace common { std::string GetUserAgent() { // TODO(jam): change depending on OS ret...
```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 "mojo/common/user_agent.h" #include "build/build_config.h" namespace mojo { namespace common { std::string GetUserAgent() { // TODO(j...
7a3936ce-5a88-4c49-a19b-7b6712035c8c
{ "language": "C++" }
```c++ ``` Add bench for image encodes
```c++ /* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "Benchmark.h" #include "Resources.h" #include "SkBitmap.h" #include "SkData.h" #include "SkImageEncoder.h" class EncodeBench : public Benchmark { public: ...
1e306fbe-d649-418d-828f-34a0fcf1bbb6
{ "language": "C++" }
```c++ ``` Add solution to the second problem of the first test
```c++ #include <iostream> using namespace std; class Pizza { char name[30]; double price; public: Pizza(const char _name[] = "", double _price = 0): price(_price) { strcpy(name, _name); } double getPrice() { return price; } }; class Order { Pizza pizzas[20]; int pizzasCount; public: O...
6d35f738-87ca-4abb-99de-8b4de18033b4
{ "language": "C++" }
```c++ ``` Add compile unit size test
```c++ // This is a regression test on debug info to make sure we don't hit a compile unit size // issue with gdb. // RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | llc --disable-fp-elim -o Output/NoCompileUnit.s -f // RUN: as Output/NoCompileUnit.s -o Output/NoCompileUnit.o // RUN: g++ Output/NoCompileUnit.o -o Output/No...
1ca09eec-be80-4f6a-b108-2f92f4cd3dd7
{ "language": "C++" }
```c++ ``` Add unit test for Generic::GetZone() function
```c++ // Copyright (c) 2019 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 "gtest/gtest.h" #include <Rosetta/Actions/Generic.hpp...
7b03a714-be96-4ce3-8eba-146176c84934
{ "language": "C++" }
```c++ ``` Implement algorithm to print symmetrix matrix
```c++ #include <iostream> using namespace std; int main() { int N = 4; char items[] = {'a', 'b', 'c', 'd'}; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cout<<items[i^j]<<" "; } cout<<endl; } return 0; }```
973e4bde-5e7f-43d0-b975-723db8fadbd7
{ "language": "C++" }
```c++ ``` Add test for variadic functions.
```c++ #include "Output.h" Output output; void varArgFunc(int numParams, ...) { __builtin_va_list ap; __builtin_va_start(ap, numParams); for (int i = 0; i < numParams; i++) output << __builtin_va_arg(ap, int); __builtin_va_end(ap); } int main() { varArgFunc(4, 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd...
e83294eb-5f88-4a73-b15a-30e074137119
{ "language": "C++" }
```c++ ``` Add regression test for FixedpointCoordinate
```c++ #include <osrm/coordinate.hpp> #include <boost/test/unit_test.hpp> // Regression test for bug captured in #1347 BOOST_AUTO_TEST_CASE(regression_test_1347) { FixedPointCoordinate u(10 * COORDINATE_PRECISION, -100 * COORDINATE_PRECISION); FixedPointCoordinate v(10.001 * COORDINATE_PRECISION, -100.002 * C...
f8566244-c7a2-4d72-ab05-7cbafdaa5843
{ "language": "C++" }
```c++ ``` Add solution to first problem
```c++ #include <iostream> using namespace std; class BankAccount { char clientName[23]; char id[15]; double account; public: BankAccount(const char _clientName[], const char _id[], double _account) { strcpy(clientName, _clientName); strcpy(id, _id); account = _account; } void print() { ...
c75dedef-5729-4b92-a132-53026f2290fe
{ "language": "C++" }
```c++ ``` Insert useful script for windows computers, standard input output.
```c++ #include <iostream> #include <stdio.h> using namespace std; int main (){ freopen("data.in", "r", stdin); freopen("data.out", "w", stdout); return 0; } ```
01ad90a2-e493-4151-9475-5b8757e9a199
{ "language": "C++" }
```c++ ``` Add output test for write under reader lock
```c++ // RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s #include <pthread.h> #include <unistd.h> pthread_rwlock_t rwlock; int GLOB; void *Thread1(void *p) { (void)p; pthread_rwlock_rdlock(&rwlock); // Write under reader lock. usleep(100); GLOB++; pthread_rwlock_unlock(&rwlock); return 0; } ...
48b066a4-0dba-4526-9e0b-5a1f4511b3d8
{ "language": "C++" }
```c++ ``` Add basic inverted index implementation in C++
```c++ #include <fstream> #include <iostream> #include <map> #include <sstream> #include <string> #include <vector> bool is_whitespace(char c) { return c == ' ' || c == '\t' || c == '\n'; } void add_words(std::vector<std::string> &dest, const std::string &s) { char *begin, *end; char t; end = begin = (char*)s.c_s...
580b5141-e9ce-4616-a48d-7a93e3d69abd
{ "language": "C++" }
```c++ ``` Add test that uses likely intrinsic to iterate over a circlular domain!
```c++ #include <Halide.h> #include <stdio.h> using namespace Halide; int count = 0; int my_trace(void *user_context, const halide_trace_event *ev) { if (ev->event == halide_trace_load) { count++; } return 0; } int main(int argc, char **argv) { Func f; Var x, y; Func in; in(x, y...
f5b9d579-8f99-4436-969d-de44dc489ae1
{ "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 "chrome/browser/extensions/extension_apitest.h" #include "chrome/common/chrome_switches.h" #include "testing/gtest/include/gtest/gtest.h" ...
```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 "chrome/browser/extensions/extension_apitest.h" #include "chrome/common/chrome_switches.h" #include "testing/gtest/include/gtest/gtest.h" ...
d7d1fd86-50ab-4f10-9268-0b9e01001e31
{ "language": "C++" }
```c++ ``` Add a chat websocket test.
```c++ #include <silicon/api.hh> #include <silicon/remote_api.hh> #include <silicon/websocketpp.hh> using websocketpp::connection_hdl; struct session { static session* instantiate(connection_hdl c) { auto it = sessions.find(c); if (it != sessions.end()) return &(it->second); else { std::uni...
f7a1af4c-64e8-4aee-84d4-bda0f4ab9a98
{ "language": "C++" }
```c++ ``` Add a C++ solution to the closed loops problem.
```c++ #include <iostream> //Function to find the number of closed loops in a given number. int closed_loops(int n){ int counter = 0; while(n!=0){ int r = n%10; if ((r==6) || (r==9) || (r==0)) counter++; if (r==8) counter+=2; n=n/10; } return coun...
481c433a-3fad-4abe-a9d0-3c56f14c0bbb
{ "language": "C++" }
```c++ ``` Add test missed from r143234.
```c++ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s namespace StdExample { constexpr int f(void *) { return 0; } constexpr int f(...) { return 1; } constexpr int g1() { return f(0); } constexpr int g2(int n) { return f(n); } constexpr int g3(int n) { return f(n*0); } namespace N { constexpr int c = 5; ...
26fab1d2-29f3-44c6-8b2e-12412fd3fee9
{ "language": "C++" }
```c++ ``` Add Solution for Problem 016
```c++ // 016. 3Sum Closest /** * Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. * Return the sum of the three integers. You may assume that each input would have exactly one solution. * * For example, given array S = {-1 2 1 -4}, and target = ...
43f3ae52-71f8-4932-9e52-855855024ad0
{ "language": "C++" }
```c++ ``` Solve problem 26 in C++
```c++ // Copyright 2016 Mitchell Kember. Subject to the MIT License. // Project Euler: Problem 26 // Reciprocal cycles #include <vector> namespace problem_26 { long recurring_cycle_len(const long n) { long dividend = 10; std::vector<long> remainders; while (dividend > 0) { // Check if the next remainder has oc...
71080f2d-7362-4466-890e-4465e2f9486c
{ "language": "C++" }
```c++ ``` Add Creator's first unit test: create_model_test
```c++ /* * bacteria-core, core for cellular automaton * Copyright (C) 2016 Pavel Dolgov * * See the LICENSE file for terms of use. */ #include <boost/test/unit_test.hpp> #include "CoreConstants.hpp" #include "CoreGlobals.hpp" #include "Creator.hpp" BOOST_AUTO_TEST_CASE (create_model_test) { ModelPtr model ...
cc4f19ef-f7a7-49e5-85ad-082a97e167b6
{ "language": "C++" }
```c++ ``` Add missing file from last commit
```c++ #include "abstractfieldwidgetfactory.h" using namespace KPeople; AbstractFieldWidgetFactory::AbstractFieldWidgetFactory(QObject *parent): QObject(parent) { } AbstractFieldWidgetFactory::~AbstractFieldWidgetFactory() { } ```
aa192925-9d67-43a6-9bdf-0d371b8a8f90
{ "language": "C++" }
```c++ ``` Add example for paging view
```c++ // Copyright 2016 otris software AG // // 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 appli...
0f8ff651-620a-4650-8f94-7f0d46bbbf9c
{ "language": "C++" }
```c++ ``` Add test for the last chapter of our C++ exception handling odyssey. llvmg++ now fully supports all C++ exception handling functionality.
```c++ #include <stdio.h> static unsigned NumAs = 0; struct A { unsigned ANum; A() : ANum(NumAs++) { printf("Created A #%d\n", ANum); } A(const A &a) : ANum(NumAs++) { printf("Copy Created A #%d\n", ANum); } ~A() { printf("Destroyed A #%d\n", ANum); } }; static bool ShouldThrow = false; int throws() try ...
d5a3089c-75a9-42c1-914a-fb7db2264a80
{ "language": "C++" }
```c++ ``` Add hello world example program
```c++ #include <agency/execution_policy.hpp> #include <iostream> void hello(agency::sequential_agent& self) { std::cout << "Hello, world from agent " << self.index() << std::endl; } int main() { // create 10 sequential_agents to execute the hello() task in bulk agency::bulk_invoke(agency::seq(10), hello); r...
bdab8e14-5296-4dd1-a496-ff849d4d7466
{ "language": "C++" }
```c++ ``` Add a test for stack unwinding in new and delete.
```c++ // RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK // RUN: %clangxx_asan -O1 %s -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK // RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os -...
c51340c5-2069-4e8b-b67a-ac599cf68cb1
{ "language": "C++" }
```c++ ``` Add partial sollution to hw1 oop-inf-2015
```c++ #include <iostream> #include <fstream> using namespace std; struct CarInfo { const char * name; int hp; }; const CarInfo CARS[] = { { "Lambordgini Murcielago", 670 }, { "Mercedes - AMG", 503 }, { "Pagani Zonda R", 740}, { "Bugatti Veyron", 1020} }; struct CarRecord { char name[24]...
eec30fa6-2f9c-4d2e-a5a5-72130ddd7c29
{ "language": "C++" }
```c++ ``` Test for atomic handling in MSan.
```c++ // RUN: %clangxx_msan -m64 -O0 %s -o %t && %t int main(void) { int i; __sync_lock_test_and_set(&i, 0); return i; } ```
d7446f23-e2a5-4946-8800-a306e49fd4db
{ "language": "C++" }
```c++ ``` Add more unix domain socket experimental program.
```c++ #include <iostream> #include <thread> #include <glog/logging.h> #include "base/concurrent/wait_group.h" #include "base/strings/string_piece.h" #include "net/socket/socket_factory.h" #include "net/socket/unix_domain_client_socket.h" #include "net/socket/unix_domain_server_socket.h" using namespace std; const ...
3ec3177a-7acb-4963-b672-a390eb5380c5
{ "language": "C++" }
```c++ #include "mbed.h" Ticker ticker; DigitalOut led1(LED1); DigitalOut led2(LED2); CAN can1(p9, p10); CAN can2(p30, p29); char counter = 0; void printmsg(char *title, CANMessage *msg) { printf("%s [%03X]", title, msg->id); for(char i = 0; i < msg->len; i++) { printf(" %02X", msg->data[i]); ...
```c++ #include "mbed.h" Ticker ticker; DigitalOut led1(LED1); DigitalOut led2(LED2); CAN can1(p9, p10); CAN can2(p30, p29); char counter = 0; void printmsg(char *title, CANMessage *msg) { printf("%s [%03X]", title, msg->id); for(char i = 0; i < msg->len; i++) { printf(" %02X", msg->data[i]); ...
bd7646de-6a6e-4af6-9dc4-dbe490cf6e51
{ "language": "C++" }
```c++ ``` Add test for non-contiguous gpu copy
```c++ #include <Halide.h> #include <stdio.h> using namespace Halide; int main(int argc, char **argv) { Var x, y; Image<int> full = lambda(x, y, x * y).realize(800, 600); buffer_t cropped = {0}; cropped.host = (uint8_t *)(&full(40, 80)); cropped.host_dirty = true; cropped.elem_size = 4; c...
0c062311-c244-46d1-a87a-08df5ec1e1fe
{ "language": "C++" }
```c++ // Copyright 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 "base/message_loop/message_loop.h" #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" #include "chrome/brows...
```c++ // Copyright 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 "base/message_loop/message_loop.h" #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" #include "chrome/brows...
69ea0239-a3b1-42e7-afd9-a8c022a17b2c
{ "language": "C++" }
```c++ ``` Add useful algorithm to bin in c++.
```c++ #include <bits/stdc++.h> using namespace std; void toBin(int x){ for (int i =31; i>=0; --i){ cout << ((x&(1LL<<i))!=0); } } int main (){ toBin(10); return 0; }```
993625ec-c40a-453c-a8c0-24a46221863a
{ "language": "C++" }
```c++ ``` Add pseudocode for top level file
```c++ #include hand_XXX_driver.h // No memory allocation outside init main{ /// This function will do all the necessary work to set up the hand: /// - Scan bus for slaves /// - If there's a hand of type XXX then /// - initialize hand [p0-m1] /// - configure hand /// Configurations ...
c170ca6a-2ae4-4f1f-adbc-a88e0317cdd5
{ "language": "C++" }
```c++ ``` Add Chapter 3, exercise 2 (using stack in stack approach)
```c++ // 3.2 - design a stack with push, pop, peek and min, all in O(1) // improvement: only push to aux stack if new value is <= current minimum; only // pop from aux stack if value being popped is == current minimum - saves space // if many values are not the minimum. // alternative: define data structure to hold ...
d2272308-deb4-4e23-9a7b-4e66bdb351d2
{ "language": "C++" }
```c++ ``` Add raw string literal versus C preprocessor test, suggested by James Dennett.
```c++ // RUN: %clang_cc1 -std=c++11 -fsyntax-only %s // RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s // expected-error@8 {{in c++98 only}} #if 0 R"( #else #error in c++98 only)" #endif ```
36bfc7b6-fc36-4ead-bf06-7603f3c1a7e5
{ "language": "C++" }
```c++ ``` Convert time in millisecs to hh:mm:ss
```c++ #include <stdio.h> using namespace std; // converts the time in millis to // human readable format in hh:mm:ss // I/P: 901000 // O/P: 00:15:01 void convertTime(int timeInMillis) { // convert millisecs into secs int secs = timeInMillis/1000; // convert secs into minutes and round off if it reaches 6...
b68a72be-66c7-430c-bdb0-7a04a06e4bc6
{ "language": "C++" }
```c++ ``` Add Solution for 143 Reorder List
```c++ // 143. Reorder List /** * Given a singly linked list L: L0->L1->...->Ln-1->Ln, * reorder it to: L0->Ln->L1->Ln-1->L2->Ln-2->... * * You must do this in-place without altering the nodes' values. * * For example, * Given {1,2,3,4}, reorder it to {1,4,2,3}. * * Tags: Linked List * * Author: Kuang Qi...
f67de597-704f-49b1-9b06-facbe4099875
{ "language": "C++" }
```c++ ``` Set up PCH for MSVC.NET
```c++ /* GNE - Game Networking Engine, a portable multithreaded networking library. * Copyright (C) 2001 Jason Winnebeck (gillius@mail.rit.edu) * Project website: http://www.rit.edu/~jpw9607/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Pu...
7b950060-39dc-492b-bf3c-6eede8fe49b2
{ "language": "C++" }
```c++ ``` Add unit tests for typedefs.
```c++ /* * Copyright (c) 2016 Kartik Kumar, Dinamica Srl (me@kartikkumar.com) * Distributed under the MIT License. * See accompanying file LICENSE.md or copy at http://opensource.org/licenses/MIT */ #include <map> #include <typeinfo> #include <vector> #include <catch.hpp> #include "rvdsim/typedefs.hpp" namespa...
92820c3d-ce29-4f01-8ad4-cdadaf86f258
{ "language": "C++" }
```c++ ``` Add a test for both arg1 and arg0 handling in the same binary
```c++ // Allow having both the no-arg and arg1 logging implementation live together, // and be called in the correct cases. // // RUN: rm arg0-arg1-logging-* || true // RUN: %clangxx_xray -std=c++11 %s -o %t // RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=arg0-arg1-logging-" %run %t // // TODO: ...
b2d7cc3b-b818-4882-a7a6-1bf89d7c07d4
{ "language": "C++" }
```c++ ``` Add unit tests for ygo::deck::Format
```c++ #include <boost/test/unit_test.hpp> #include <ygo/deck/Format.h> #include <ygo/deck/DB.h> struct Format_Fixture { Format_Fixture() { ygo::deck::DB::get().path("test/card.db"); } }; BOOST_FIXTURE_TEST_SUITE(Format, Format_Fixture) BOOST_AUTO_TEST_CASE(Create) { auto formatDates = ygo::d...
f639a47c-e9a0-4161-a8be-4cc66a562ab3
{ "language": "C++" }
```c++ ``` Add test for last commit
```c++ // RUN: clang-cc -fsyntax-only -verify %s template<typename T> struct X0 { void f(); template<typename U> void g(U); struct Nested { }; static T member; }; int &use_X0_int(X0<int> x0i, // expected-note{{implicit instantiation first required here}} int i) { x0i.f(); // ex...
c34dfd0d-9caf-4ae9-b4a4-19067f3cb08f
{ "language": "C++" }
```c++ ``` Add Windows test for handle_segv and SetUnhandledExceptionFilter
```c++ // RUN: %clang_cl_asan -O0 %s -Fe%t // RUN: env ASAN_OPTIONS=handle_segv=0 %run %t 2>&1 | FileCheck %s --check-prefix=USER // RUN: env ASAN_OPTIONS=handle_segv=1 not %run %t 2>&1 | FileCheck %s --check-prefix=ASAN // Test the default. // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=ASAN // This test exit...
3bd95167-8254-4084-842f-81d958d5d80e
{ "language": "C++" }
```c++ ``` Split Array into Consecutive Subsequences
```c++ class Solution { public: bool isPossible(vector<int>& nums) { int st=0; for(int i=1; i<nums.size(); i++){ if(nums[i]-nums[i-1]>1){ if(!work(nums,st,i-1)) return false; st = i; } } return work(nums,st,nums.size()-1); }...
dc45d032-132a-4f5f-ad74-ee099ceac666
{ "language": "C++" }
```c++ ``` Add dynamic convex hull trick, stolen from niklasb
```c++ const ll is_query = -(1LL<<62); struct Line { ll m, b; mutable function<const Line*()> succ; bool operator<(const Line& rhs) const { if (rhs.b != is_query) return m < rhs.m; const Line* s = succ(); if (!s) return 0; ll x = rhs.m; return b - s->b < (s->m - m) * ...
3cc1597f-3495-40cf-bb09-601cd381611c
{ "language": "C++" }
```c++ ``` Make a standard input/output socket module mostly for testing purposes.
```c++ #include "sockets.h" class StandardInputOutput : public Socket { public: StandardInputOutput(); unsigned int apiVersion() { return 3000; } std::string receive(); void sendData(const std::string& data); }; StandardInputOutput::StandardInputOutput() : connected(true) {} std::string StandardInputOutput:...
3e48887c-4d2f-45c7-b108-4678ec5a3b4f
{ "language": "C++" }
```c++ ``` Add unit test for SVMOcas
```c++ #include <shogun/classifier/svm/SVMOcas.h> #include <shogun/features/DataGenerator.h> #include <shogun/features/DenseFeatures.h> #include <shogun/evaluation/ROCEvaluation.h> #include <gtest/gtest.h> #include <iostream> using namespace shogun; TEST(SVMOcasTest,train) { index_t num_samples = 100, dim = 10; fl...
3ba2f0b7-f23a-4ce9-9b76-049673021bff
{ "language": "C++" }
```c++ ``` Add simple c++ insert test
```c++ #include "skiplist.hh" #include <vector> #include <thread> #include <iostream> static unsigned int seed; void insert(Skiplist *s, int n) { for (int x=0; x < n; x++) { unsigned r = rand_r(&seed); int *v = (int *) skiplist_malloc(sizeof(int)); *v = r; Item *itm = newItem(v, si...
4b67de31-2496-4491-ab3e-1421aaa44cb5
{ "language": "C++" }
```c++ ``` Return number of set bits if int is palindrome. Question commented inside.
```c++ /* Given a number, return the number of set bits of the number if binary representation of the number is a palindrome, else return ­1. Condition : You can’t use array or any other data structure. Eg . Input 37 Output ­1 Input 165 Output 4 */ #include <iostream> #include <string...
92e03504-49e8-4166-894c-f6abb12789d9
{ "language": "C++" }
```c++ ``` Add a testcase for __ubsan_default_options() function.
```c++ // RUN: %clangxx -fsanitize=integer -fsanitize-recover=integer %s -o %t // RUN: not %t 2>&1 | FileCheck %s // __ubsan_default_options() doesn't work on Darwin. // XFAIL: darwin #include <stdint.h> extern "C" const char *__ubsan_default_options() { return "halt_on_error=1"; } int main() { (void)(uint64_t(...