C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

learn more… | top users | synonyms

4
votes
0answers
23 views

Templated Tokenizer Functions

I wanted to be able to tokenize a few different containers so I created a generic way to do it. I originally wrote this in Visual Studio 2012, but I had to modify it to get it to compile on Ideone. ...
3
votes
0answers
27 views

C++11 reentrant atomic spinlock

Could you please review my spinlock implementation? ...
0
votes
0answers
30 views

Create a custom discrete distribution that updates every 1000 iterations [on hold]

I am working on a biological game theory summer project. I want to define a discrete probability distribution that updates every 1000 iterations of the game. I think I am using the ...
-4
votes
2answers
64 views

Is the Copy-Swap Idiom implemented here correctly? [on hold]

Is the Copy-Swap Idiom implemented here correctly? ...
3
votes
2answers
54 views

Recognizing number representation (and convert to decimal) from the base prefixes

Here is what appears to be a fairly easy problem: Write a program that prompts the user to enter several integers in any combination of octal, ...
3
votes
0answers
48 views

Lua binding for C++ render engine

I've been recently working on a Lua API for my C++ (11) render library. It really has grown at the point that I think scripting would make things much easier. I've implemented a Lua interface for some ...
4
votes
4answers
210 views

Engineering a minimalist image interface without templates

I'm practicing different ways of class design, so I'd like feedback on the design characteristics. Of course code practice comments are also welcome. It was a conscious decision to omit templates. My ...
4
votes
1answer
55 views

Mangling the words of a sentence

Original Problem Statement Problem Analysis Task: Given a sentence, mangle each word and output the result. Clarifications: Mangling will be defined as a word with its ...
1
vote
0answers
30 views

Calculating the average of all grades [on hold]

I'm attempting to write a simple program for teacher. It is simply a program that calculates the average of all the grades entered by the teacher. However, I attempted to make it a little more ...
1
vote
0answers
25 views

Creating class method using macro to accept Visitator for each of their fields

I had a lot of classes that used a macro with listed fields. The macro was used to serialization, more like MSGPACK_DEFINE. I need a substitution of this mechanism, ...
4
votes
2answers
61 views

Heap implementation of the “median maintenance” algorithm

I have implemented a heap data structure for Coursera's algorithms course. The problem I have to solve is: The goal of this problem is to implement the "Median Maintenance" algorithm. The text ...
16
votes
5answers
1k views

Inventorizing the universe

I recently started re-factoring a project I hadn't touched in many months. The original purpose was to be an inventory management system for a game I played, Ogame. In this game you play inside a ...
3
votes
1answer
56 views

Hybrid Lock Implementation

I have an algorithm that is painfully slow if I use 'pure' mutexes. That's because most of the critical sections are short and far shorter than the work to sleep a thread. However, it is also slower ...
4
votes
1answer
85 views

Hash table for Coursera's algorithms course

I implemented a hash table for Coursera's Algorithms and Design class. I am looking for feedback on coding style and other improvements. I want to practice C++ coding but I see myself drifting to C ...
-1
votes
0answers
35 views

Codeforces problem set 556B: Case of Fake Numbers [on hold]

This is the problem I am working on! Note: This is not a competition, just a problem set. So this is my code. The compiler I am using is GNU C++11. This code runs fine with all the test cases ...
3
votes
1answer
43 views

Non-blocking solution to the dining philosophers

This is one of tasks, which I had to do for the recruitment process to be started in some company. Unfortunately they didn't like it so I've decided to share it here for discussion. Philo5.h ...
5
votes
4answers
182 views

Two Fibonacci functions

These are two of tasks, which I had to do for the recruitment process to be started in some company. Unfortunately they didn't like it so I've decided to share it here for discussion. Add up all the ...
7
votes
3answers
211 views

Calculating the area of a circle

This is one of tasks, which I had to do for the recruitment process at some company. Unfortunately they didn't like it so I've decided to share it here for discussion. CircleArea.h ...
3
votes
3answers
57 views

Dynamic resizeable array

How can I improve this code for a dynamic and re-sizable array data structure? Array.h ...
8
votes
1answer
76 views

C++ SQL wrapper/Statement

Part 2: (Part 1) Working on my SQL project at last. The concept is easy to use and integrate SQL into C++. ...
8
votes
0answers
37 views

C++ SQL wrapper/Connection

Working on my SQL project at last. The concept is easy to use and integrate SQL into C++. ...
4
votes
2answers
47 views

Linear cryptanalysis of a substitution permutation network

I was translating a script I had that would automate linear cryptanalysis of SP networks from Python to C++. For those who aren't familiar with cryptography, linear cryptanalysis involves finding ...
0
votes
0answers
16 views

Testing if object is not deleted [closed]

My object creates an thread and that thread modifies object-creator during his life cycle. The problem is, that thread should not invoke objects methods when it is destroyed. I have found some ...
3
votes
2answers
67 views

Fastest way to search istringstream for patterns in around 0.02 seconds

Problem I have a stream composed of 2 columns and 1000 lines: Column 1: contains the patterns that I want to find Column 2: contains the values corresponding the the patterns in Column1 I want to ...
2
votes
1answer
40 views

Program simulating dictionary using file handling - part 2

This is the new version of the dictionary program which I uploaded for reviewing here. I would be grateful if the program could be reviewed for all the points mentioned in the above link. ...
1
vote
0answers
12 views

Range Query - Range Update

This is the problem statement: In most of the range query-update questions, we are asked to update some range of the array with some constant_value which can be ...
4
votes
1answer
69 views

C++ Trie Implementation

I recently tried a basic C++ implementation of a Trie, and was looking for some feedback on my code style/choices. In particular I was wondering if I'd made the right choice spitting the program up ...
5
votes
1answer
52 views

A* algorithm solution to “intermediate space probe” challenge

This code is my solution to this Reddit challenge: Description: NASA has contracted you to program the AI of a new probe. This new probe must navigate space from a starting location to an end ...
0
votes
0answers
25 views

Hash table with “Time To Live” elements

Recently, I got a very interesting task: to realize the hash table that works in multi-process server in common memory, each element of which must have a TTL property. It was suggested to implement ...
6
votes
3answers
70 views

Parallel factorial algorithm using std::thread

This code calculates the factorial of a number on multiple threads. My issue: it is only a little bit faster than the sequential version of it (and I think I know why, I just can't find a way to solve ...
5
votes
1answer
57 views

Histogram of a RGB image using OpenCV

I wrote some C++ code using the OpenCV library. The program reads the image and plot histograms of Red, Green, and Blue components. I am very new to OpenCV so I need comments and advice. What do you ...
4
votes
3answers
148 views

Writing a large file of numbers

Basically, I want to write a huge file of numbers. Each line in that file should contain one number. This program below is extremely slow (obviously) but it works. It writes one line after line and ...
5
votes
1answer
88 views

Implementation of std::vector class

I decided to implement the std::vector class in C++, and was wondering if I had done everything correctly. When I mean 'correctly', I mean that the code is ...
2
votes
0answers
30 views

Performane issue for Matlab-like reshape in OpenCV

I am translating Matlab code to OpenCV. The code involves lots of reshaping of large matrices. As the Matlab reshape differs from OpenCV you can't just use OpenCV reshape. Here is why: Let's suppose ...
0
votes
2answers
33 views

Understanding exceptions in a constructor (by the conversion C-string to long example)

I myself is a Java-developer and now I'm trying to understand how to do it in the most efficient way in C++. After reading that answer I decided to write the following: ...
3
votes
2answers
77 views
6
votes
1answer
81 views

Lock-free bounded stack in C++11

Here is a classical attempt to implement a lock-free stack (based on this article). I rewrote it in C++11 and also tried to add memory orders which I would like to confirm to be correct. ...
1
vote
2answers
70 views

Logging mechanism

I have the following code: ...
4
votes
1answer
79 views

Lock-free bounded stack atomics

I was thinking about using very basic bounded (preallocated) stack to keep track of my threads IDs in correct LIFO order. I was wondering if my implementation is thread safe: ...
0
votes
1answer
58 views

“Largest prime factor” - C++ version [closed]

Hello I am trying to solve the ProjectEuler #3, the largest prime factor problem, here is the specification: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor ...
4
votes
2answers
68 views

SDL Input Managment

I've created an SDL input manager for my 3D OpenGL applications. It's not finished yet, but I would like to know if I'm doing it the right way. I really tried to optimise and compact my code, as it ...
2
votes
1answer
66 views

Count of anagrams of a text in a given string

Problem Statement: Given a word and a text, return the count of the occurences of anagrams of the word in the text. For eg. word is “for” and the text is “forxxorfxdofr”, anagrams of “for” ...
3
votes
1answer
37 views

Implementation of FastICA in multithreading approach

I am to implement a parallel version of FastICA, so I implemented the serial version of FastICA. Now this is the architectural diagram of how it is going to parallelize. I just coded a basic ...
8
votes
2answers
108 views

Parsing a simple tuple “(float,float,float)” in c++11 iostreams

I spotted this tutorial example at compactcpp: #5 – Parsing strings into “tokens” ...
10
votes
1answer
91 views

Compile-time sieve of Eratosthenes

There are many instances of prime number sieve implementation both here and other places on the web, but I wanted something a little different. In particular, I wanted to create a static array of the ...
6
votes
1answer
48 views

Pool allocator for a scripting language parser

At the moment I'm writing a parser and interpreter for a custom scripting language, to learn more about the basic concepts involved and to get more familiar with tools like ...
3
votes
2answers
73 views

Auction Algorithm Optimization in C++

I have written the following Auction Algorithm implementation in C++ and I am having issues with performance. On my machine a problem size of 500 is solved in about 7 seconds while a similar Matlab ...
1
vote
1answer
43 views

JARJAR challenge on SPOJ

I tried this problem and I saw that my solutions was way too slow compared to others. I want to know how I can improve time complexity. A job has been assigned to Jar Jar Binks, it goes as ...