All Questions
Tagged with container or collections
355 questions
4
votes
1
answer
89
views
A matrix class for objects other than numbers
I'm in the process of writing a matrix like container to store objects. Despite many existing matrix implementations, I won't do numerics. Instead I want to replace a ...
5
votes
1
answer
148
views
Allowing switching between operator[] and at() based on NDEBUG macro version
The problem:
std::vector and other containers have two functions for accessing / modifying their content: operator[] and ...
1
vote
1
answer
157
views
A unique_ptr-like class, for spans instead of raw pointers
Introduction / Motivation
I like the CADRe (a.k.a. RAII) resource management idiom in C++. And I like std::span's; or perhaps I should say, I dislike the use of ...
3
votes
0
answers
136
views
Simulating Objects with Collections in VBA
Background
I am writing a VBA module which requires the functionality of a custom object. This object will support "regular" functions (UDFs) within the module.
Due to reasons beyond the ...
5
votes
1
answer
118
views
Update Member "In Place" within VBA Collection
Background
I encountered this issue a while back, where I tried to "set" the value of a member "in place", without changing its position within the ...
4
votes
1
answer
66
views
Implementing Intersections data structure that is able to hold a container of multiple types that maintains order in C++
I am trying to implement a way to store intersections of rays with arbitrary objects. So far I thought I could make the object derived from an interface and put that as the type in the Intersection ...
5
votes
2
answers
965
views
Optimized data structure mapping finite set of integers to values in C++
I'm looking for a mapping data structure, but knowing that the possible values of my keys are small numbers, I would like to trade memory for better performances (for both random access and value ...
6
votes
2
answers
94
views
TypeScript Number Set
I originally premiered this code to the internet in this StackOverflow post, and per a recommendation through one of the comments, I am reposting it here.
I am making a floating-point number set ...
6
votes
3
answers
1k
views
Simple Container Class
I'm learning C++ and trying to create my own container class just for practice (I know about vector, list, map, set). I plan to improve this class and add new methods as I learn new material. Please ...
13
votes
1
answer
4k
views
Container with sorted by multiple keys
From this question:
Sorted vector (aka flat_set) for objects (pointers) with custom embedded key (functor used)
This is an example of a multi-index container. Note: this is not a container as ...
2
votes
1
answer
88
views
Generic container wrapper type with a default underlying buffer (2nd rev)
This is a revision of the previous question. I was told to ask an additional question with more context for the modified code to be reviewed.
The changes:
changed from ...
2
votes
1
answer
62
views
Looking for feedback on a flavour of Radix tree I wrote. This is version 2 of the class original posted on this forum
My project explores some ideas i've had regarding alternate data structures to the unorderd_map and map, and aiming the exploration to key sets with a non uniform distribution and key sets with common ...
4
votes
1
answer
192
views
Looking for feedback on a flavour of Radix tree I wrote. The idea is speed on find() time if keys share common prefixes and are known ahead of time
My project explores some ideas i've had regarding alternate data structures to the unorderd_map and map, and aiming the exploration to key sets with a non uniform distribution and key sets with common ...
2
votes
1
answer
52
views
A collection based on a bitset to store a set of unique integers from a given range (rev. 3)
All right, let's do this one last time.
This is continuation of this review.
I applied most of the proposed changes, making interface of my container very close to that of ...
4
votes
1
answer
86
views
A collection based on a bitset to store a set of unique integers from a given range (rev. 2)
This is a continuation of this review. I applied most of the proposed changes.
These changes were focused mostly on decoupling the class from the rest of the program and making its interface more like ...
1
vote
1
answer
86
views
Collection that uses a bitset to store a huge set of unique integers from a given range (rev. 1)
Some (skippable) context:
I'm writing program that minimizes an arbitrary logical function. Such function takes an unsigned integer as an argument and returns either ...
2
votes
3
answers
121
views
A dynamic array with an iterator compatible with std::sort
I wrote a Vector (dynamic array) class with an iterator usable with std::sort() . It seems to pass my tests.
I wondering about the issues one can spot on this ...
1
vote
1
answer
133
views
SynchronizedObservableCollection: a thread-safe ObservableCollection
After reading many people talk about the need for a SynchronizedObservableCollection and their implementations I decided to roll my own. I wanted to add a ...
2
votes
2
answers
2k
views
C++ ring buffer using some C++ 17 and coming C++ 20 std::span
When I heard about the new Linux I/O interface io_uring I searched about the ring buffer.
I then thought I may replace my safe queue which is base on C++ 11 ...
4
votes
2
answers
1k
views
C++20 "FixedArray" Container (dynamically allocated fixed-size array)
I've wrote a FixedArray to fit seamlessly (function-wise) with the default C++ containers, including working with algorithms/etc. It is a dynamically allocated, but fixed size array.
Code
...
3
votes
1
answer
131
views
std::list reimplementation for practice
I used cppreference list to implement this simplified std::list.
The CXX_STANDARD is 11.
My questions are the usual:
Is the ...
1
vote
2
answers
656
views
Implemented Sorting of Map by Value and then by Key in java
So I had this requirement to get the frequency of names appearing in a list
and then print the one appearing the most number of times. If there is a clash, print the one which comes first in the ...
5
votes
2
answers
4k
views
Bidirectional map based on memory manipulation
This is a bidirectional map implementation that stores the values as pairs on the heap, and uses pointer arithmetic for efficient lookup.
codepad link, may be easier to read
...
3
votes
6
answers
10k
views
Divide group of numbers into two groups of which the sums are equal
I have a piece of code that divides a group of numbers into two groups of numbers of which the sums are equal.
I created this because of a Stack Overflow question:
For example:
{10,15,20,5} will ...
3
votes
2
answers
425
views
C macro based dynamic array library
This library is a fork of eteran/c-vector. It is macro based, so that it is generic, without void pointers and additional functions. This of course means that it has the downsides of macros in C. The ...
4
votes
2
answers
157
views
Sort a dict by keys, assuming keys are orderable
I found a suspicious code snipped in an existing project in which I am involved as a developer. The code sorts a dict by its keys, so that if iterated over the dict,...
3
votes
1
answer
474
views
Yet another sparse set implementation
I got inspired by this blog post and implemented a fixed-size sparse set, removing the need for vectors, because the sparse set's size equals at least ...
6
votes
2
answers
1k
views
A not so simple C++20 circular queue
This container reduces the number of memory allocations on queue-type operations (push + pop) compared to std::deque. Basic performance tests indicates a performance similar to std::deque where main ...
2
votes
1
answer
242
views
Simple C++ circular queue
I wrote a simple C++20 circular queue.
https://github.com/torrentg/cqueue
Here is cqueue.hpp
...
8
votes
3
answers
5k
views
Piling Up with Python
This is my solution for a Hackerrank problem. The problem was:
There is a horizontal row of cubes. The length of each cube is given. You need to create a new vertical pile of cubes. The new pile ...
0
votes
1
answer
49
views
Iterating over JSON more effectively
Problem:
I need to get data from JSON file containing information about "contributors". Each contributor has an atrribute jobs, which is a list of string-...
1
vote
1
answer
109
views
Class that wraps a collection and tracks if its elements were visited
The VisitedCollection is a collection wrapper for setting and tracking if elements were visited (removed in terms of the wrapper)
I have concerns regarding:
should ...
2
votes
3
answers
171
views
How to efficiently build an object from list or array of strings
I am working with an API that delivers some data in a QStringList or basically a list of strings. The data contains keys and values but it is not a ...
0
votes
1
answer
1k
views
std::list implementation learning exercise
I want to improve my algorithms and data structures in C++ understanding and also learn how the standard library containers are implemented. I implemented a std::vector in a previous review and this ...
0
votes
1
answer
2k
views
Faster way to find items from one list in another one [closed]
I would like to check if a string appears in a list of strings. For that, I have chosen the List<string> type, as follows:
...
5
votes
1
answer
305
views
C smart string implementation using preprocessor
I have wrote a smart string container implementation for use in my application, but as I'am not such professional C programmer I have doubts about is I'am did it right and is there ways how to improve ...
5
votes
2
answers
204
views
std::vector implementation learning exercise
I want to improve my algorithms and data structures in C++ understanding and also learn how the standard library containers are implemented. This resizing_array is based on the std::vector.
My ...
-1
votes
1
answer
82
views
Most efficient way to track a collection of targets in range of a source object [closed]
In my game there are space ships and each of these space ships tracks which other ships are in range of it. I need to perform certain logic when a target ship comes in range of another ship, and ...
0
votes
1
answer
246
views
Action on each element of an inline list
I'm trying to learn the "functional" part of C#/.Net for work, and I'm not sure if this is a good way to write this statement.
I was also trying to reduce duplicated code while not ...
3
votes
1
answer
89
views
C Typed Vector that implements type-safety, encapsulation and lazy initialization
C Typed Vector
I wasn't happy with the various dynamic array / vector implementations in C, so I made my own. In general, I'm not the biggest fan of C-preprocessor madness, but alas for this ...
3
votes
0
answers
241
views
Implementation of Dynamic Array with allocators and C++20
To train my skills in C++, I decided to implement the well-known "Dynamic array" data structure on my own. I realized early on that using pointers or smart pointers is wrong, as it leads to ...
3
votes
2
answers
427
views
Prime numbers iterator
I am not familiar with iterators. I am confused with the traits approach and the traditional one. I don't know which one I should use in 2021.
I wrote a minimal ...
7
votes
1
answer
348
views
Custom implementation to provide an immutable range of a container without copying it
I needed to pass a const reference to part of a std::vector without copy. I posted the previous version in my earlier question, thank you for the great support! As ...
13
votes
1
answer
244
views
Multi-function memoizator and multi-type container
I'm trying to write a multiple functions memoizator, which I've talked about here. The main problem is creating a container containing different and heterogenous functions.
I found a working solution,...
1
vote
2
answers
106
views
Is there a way to simplify getting the character that appears the most in a collection with Linq?
I have a collection of strings, all of which are three characters in length:
...
4
votes
2
answers
2k
views
Implementing an HotelManager interface in Java
Got a mission to implement an Hotel Manager interface.
I will post the interface and the attached class Reservation, and will add my code.
What I am asking you is ...
2
votes
1
answer
1k
views
Python script to automate the creation of Linux LXC containers
Like the title suggests, I wrote a script in Python that uses the python3-lxc library to automate the creation of Linux LXC containers. I realised that containers ...
3
votes
3
answers
480
views
Efficient way of flat mapping a range of a multidimensional random access collection
I've recently answered a question about reading elements from an array of arrays. A way it could be interpreted is that the OP wanted to read a range that could span over multiple subarrays of the 2D ...
3
votes
1
answer
62
views
Dependency Container
I'm currently creating my own microframework for learning purpose and I want to make it more powerful by providing a way to register classes and instantiate them (once) only when needed. So here is my ...
1
vote
1
answer
1k
views
A multi key/value type "folded" map class template
I have recently come across a use case where I need to lump many maps into a single container. These maps can have different combinations of key/value types, but they all differ from one another.
For ...