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

learn more… | top users | synonyms

1
vote
0answers
24 views

Typetokens in C++11

I have written a typetoken library in C++11 and I want to know if it is indeed typesafe, threadsafe and complete. The purpose of this library is to give an unique ID to every requested typename ...
0
votes
1answer
33 views

Tic-Tac-Toe in C++11 - follow-up 3

Previous question: Tic-Tac-Toe in C++11 - follow-up 2 Here, AI is being implemented. ...
1
vote
0answers
31 views

Optimizing insertion sort for small amounts of data

I'm building a hybrid sort, and for that I need a fast and adaptive sort ideal for small sizes (< 65 elements). Insertion sort immediately comes to mind, and I've been tinkering with different ...
6
votes
2answers
315 views

Strategy pattern - design hash table

My programming skill has gotten rusty, so I would like to elicit constructive criticism that can make me write code better. I know the standard design is to use templates, and even obtain the hash ...
1
vote
2answers
78 views

Tic-Tac-Toe in C++11 - follow-up 2

Previous question: Tic-Tac-Toe in C++11 - follow-up Is there any way to improve this code? ...
3
votes
2answers
116 views

Compute (x+yCx)%mod

I want to compute, as quickly as possible, $$ \dfrac{(x+y)!}{x!y!} \mod m $$ with \$x,y \le 10^6\$ and a prime \$m=10^9+7\$ (called mod in my code). My current ...
2
votes
2answers
65 views

C++ Prime Factorization

I just picked up C++ today and I wonder if this is c++-like. I have a bit of experience with Java. This is a program that takes a number as input and outputs its prime factorization in no particular ...
8
votes
1answer
56 views

Snippets Manager

This basically manages a set of snippets, saving and loading it. snippets.cpp ...
2
votes
2answers
80 views

Binary Search Tree in C++

I'm writing C++ for the first time and wanted to implement a BST. I come from writing C, so I tend to write code in that way. I'm trying to wrap my head around smart pointers, but can't seem to get ...
2
votes
2answers
43 views

Basic myVector class raw vs smart pointer

I'm writing a myVector class for a class I'm taking. I don't believe I'm "strong" with smart pointers right now, so that's my question. This is just an excerpt ...
3
votes
3answers
99 views

AVL tree for inserting and searching

I have made an AVL tree. It works and does what it needs to do. I only need it to insert and search. I am comparing how long it takes to load and search a dictionary file in relation to other various ...
2
votes
2answers
166 views
5
votes
3answers
99 views

Append a string to each line in a file

I wrote (several months ago) a program that will take an input file, with a provided std::string, and append that to each individual line in the file. Looking at ...
1
vote
2answers
57 views

Vector/matrix class

Some definitions: ...
3
votes
1answer
35 views

Prim algorithm implementation for adjacency list represented graph

Please review the implementation of Prim algorithm. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed based on their data. ...
1
vote
0answers
21 views

Kruskal algorithm implementation for adjacency list represented graph

Please review the implementation of Kruskal algorithm. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed based on their ...
-1
votes
0answers
17 views

Code reads user input and keeps asking them for answer until it falls within specifications [on hold]

So, what I'm trying to do is make it so that the user has to keep entering things in until they follow the specifications listed, which is it has to be a number between 1 and 5. But that happens is ...
3
votes
0answers
34 views

Djkistra shortest path implementation for adjacency list represented graph

Please review the implementation of Djkistra algorithms. Points on which I have doubt: My Graph doesn't have any ID for nodes. Nodes are accessed based on their ...
5
votes
2answers
99 views

Stack with a minimum

A practice interview question: How would you design a stack which, in addition to push and pop, also has a function getMin which returns the minimum element? Push, pop and min should all operate ...
0
votes
0answers
25 views

Is using for loops the only method to perform matrix multiplication in C/C++? [on hold]

for (i = 1; i <= x; i++) for (j = 1; j <= z; j++) { c[i][j] = 0; for (k = 1; k <= y; k++) c[i][j] += a[i][k] * b[k][j]; } I ...
4
votes
5answers
292 views

Creating vector of primes using Sieve of Eratosthenes

Please review my Sieve of Eratosthenes implementation. ...
4
votes
4answers
142 views

Tic-Tac-Toe in C++11 - follow-up

This is based on my first Tic-Tac-Toe game: Tic-Tac-Toe game in C++111 i have come up with different game logic for my game. I would like to know which one is more reliable and effective and how to ...
0
votes
0answers
17 views

Merge Sort Variant: Using array link [closed]

I was looking for the variants of Merge Sort. So my textbook says, A variant of function Merge in which No records need to be moved at all, can be implemented by use of an auxiliary array links. ...
5
votes
3answers
151 views

Small command-line helper tool

I've coded a small command line helper tool for this library I'm working on. The library provides tools for the use of Virtual Texturing on iOS devices (mainly games). This little command line helper ...
5
votes
4answers
269 views

Using std::unique_ptr and std::move

I'm trying out new things (on class Inproc), specifically using std::unique_ptr and ...
6
votes
5answers
415 views

Tic-Tac-Toe in C++11

I have found Tic-Tac-Toe source code: Tic Tac Toe in C++ I have rewritten the source code in C++11 as shown below. How can I minimize hardcoding in the game logic? ...
-2
votes
0answers
12 views

Tic Tac Toe CMD [closed]

Im making a command line version of Tick tack Toe for my class yet I keep running into the same problem it keeps stoping after player one take his first turn no player 2 no call back to player one ...
1
vote
2answers
99 views

Octree code performance

I'm using a simple Octree in my program, wanted to know if my implementation could be faster. It is part of this program: https://github.com/Mortis69/rendera Octree.H: ...
-1
votes
0answers
18 views

C++ code problem. Input needed [closed]

There are several problems with my code: I am trying to create a menu but it goes to infinite loop when a letter or character is put in. It is the same if I used the function ...
2
votes
1answer
43 views

Implementation of a singly linked list

I wonder if the code below is a good (quality and correctness) implementation of a single linked list in C++, in regard of data structure (not the exposed interface). ...
1
vote
0answers
30 views

Treap with implicit keys

I implemented an implicit treap and tested it a little. It works fine but I'd like to know if there are ways to improve/simplify things and/or if some parts are incorrect. Later, I'll augment code to ...
2
votes
2answers
81 views

Superior improved stack implementation using a linked list

Please review my hopefully improved stack implementation As suggested by some answers to my previous code, some of the functions can be overloaded to provide versions of return by value, return by ...
1
vote
2answers
48 views

ostream wrapper for network logging device

I want to be able to write logging data out to a network device with the same ease as using std::cout. So I implemented an ...
11
votes
2answers
106 views

Allowing the user to alphabetize or randomize the contents of a text file

As a newbie programmer, I decided to try my hand at making a program whose function actually might be useful to someone, somewhere. This utility takes a text file, reads it out to the user, displays ...
5
votes
2answers
81 views

Thread-safe Phoenix Singleton class template with Boost

I've implemented the phoenix-singleton as a class template with boost inspired by Modern C++ Design. The code compiles fine with MSVC 2013 - and it seems to work, but I'm new to multi-threaded ...
0
votes
0answers
26 views

Radix sort (LSD) and Counting sort

I'm reading CLRS, and to practice, I rolled my version of radix sort and counting sort. I was looking at some reference implementations, particularly the LSD one from rosetta code, and mine performs ...
1
vote
1answer
33 views

Homogenising iterator and const_iterator

I've reworked (for C++11) a section of PyCXX which contained an almost identical iterator and const_iterator. I would like to ...
4
votes
1answer
29 views

Less insane interface design for a trigger component for T types?

Disclaimer: I just asked this on the regular SE, but was suggested to post it in here since it's kind of a code review. I've recently been playing around with component frameworks, and I'm trying to ...
0
votes
0answers
27 views

returning bool from member variable pointer [closed]

So I'm working with this code that looks like this: ...
5
votes
1answer
79 views

Simple simulated annealing template in C++11

This simulated annealing program tries to look for the status that minimizes the energy value calculated by the energy function. The status class, energy function and next function may be ...
-3
votes
0answers
27 views

Implementing Insertion Sort Using 3 Stacks. (Segmentation Fault - Core Dump) [closed]

I'm getting a Segmentation Fault - Core Dump during runtime. EDIT: Added Input and Output below. ...
7
votes
3answers
116 views

Design a Tips class that calculates the gratuity on a restaurant meal

Design a Tips class that calculates the gratuity on a restaurant meal. Its only class member variable, taxRate, should be set by a one-parameter ...
2
votes
1answer
49 views

Driving 7-segment displays

I made a little JavaScript app here that let people generate bitmap for generating characters. Currently it generate code of a dictionary. But I want to also generate a example that let them play like ...
8
votes
3answers
201 views

Finding shortest paths in directed graphs

I have very little experience in programming with C++ and the following small "program" is the 2nd one I have ever written in that language. I am most interested in comments regarding naming ...
8
votes
1answer
65 views

consecutive_find function for returning a consecutive range of elements

consecutive_find() is a function that returns the beginning of a range that contains strictly N consecutive elements. It was part of a SO question that I answered. ...
6
votes
4answers
459 views

Sum of digits in a^b

I'm trying to calculate a problem which requires sum of digits in \$a^b\$, where \$0 \le a \le 9\$ and \$0 \le b \le 4000\$. I have seen various other posts similar to this, but I haven't acquired ...
7
votes
4answers
531 views

Given n numbers, find out the least k numbers from them

I have been solving the following problem: Given n numbers find out the least k numbers from them. For example, if there are 8 numbers like 5,6,3,4,7,8,9,-1. For k = 3 the result will be -1,3,4. ...
0
votes
1answer
40 views

Matrix: Set a row/col to zero

A practice interview question: Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0. ...
1
vote
0answers
44 views

Reader/writer spinlock

I wrote some code for a reader/writer spinlock that gives some preference to writers. Is the code correct? The code uses readerCount for the actual locking and just ...
2
votes
1answer
61 views

Multithreading pthread program

My multithreaded version of code works slowly than singlethreaded. Can you help me to understand why? ...