Questions tagged [array]
An array is an ordered data structure consisting of a collection of elements (values or variables), each identified by one (single dimensional array, or vector) or multiple indexes.
2,122 questions
0votes
0answers
19views
Identifies connected elements and faces in FE mesh
So I'm conscious that this is a weak appeal for best practices. I'm building a converter that moves generic FE meshes to an inhouse edge format in Fortran and at some point I made a truly diabolical ...
6votes
7answers
1kviews
Filter non-even elements from an array
I have a method that returns an int[]. The array is made by filtering out only the even values of the array passed into the method. It works, but it's really ugly ...
2votes
1answer
33views
Zig: Basic map and movement logic
I'm interested about choice of types for storing coordinates; since the type for indexing an array is usize, that is what I chose. I feel something might be wrong ...
3votes
1answer
97views
Swift Arrays: Write a rotate-right function
Task: Write a function which rotates all elements of a given array to the right. Example: [1, 2, 3] => [3, 1, 2] My solution: ...
1vote
2answers
388views
Median of two sorted arrays in Python
Problem Statement (Source: Leetcode Problem 4: Median of Two Sorted Arrays [Hard])(Topics: [Array] [Binary Search] [Divide and Conquer]) Given two sorted arrays ...
3votes
1answer
91views
Merge discrete integer intervals
What it does The code starts with a set of integer intervals, and can add new intervals (possibly by updating existing intervals). Essentially, it is a bit array whose index starts at ...
6votes
3answers
333views
Implementation of arrays that store their size
In this code I implemented arrays that store their own size before the first element. To access it you need to go back exactly sizeof(size_t) bytes back. To free it,...
7votes
3answers
990views
Dynamic Arrays with Count / Capacity in C
I write in C for several projects (e.g. learning / teaching, coding competitions, data processing) and frequently need arrays (e.g. strings) with fast appending / concatenation / reversing. I've ...
3votes
2answers
86views
Optimize Working Live Search & Highlight Function
I've written a custom Live Search & Highlight function in vanilla JS. It is working and does what I expect it to. The issue is that the more items I add to the page content to search, the slower ...
3votes
2answers
145views
Todo List app using C
I just learned to deal with pointers and memory allocation stuff. Using that, I built a todo list app, and it works as far as I tested it. I didn't account for many user errors, so any suggestion to ...
3votes
0answers
98views
Comparing two Tree sort algorithm variations implemented in Java
I have this repository. It contains three variations of a simple sorting algorithm for integer keys. The idea is that we keep a balanced BST in which each node holds the integer key and its frequency. ...
0votes
0answers
33views
Removing "all" entries of Type from an array (Godot Editor)
I realized I wanted a way to safeguard for null entries, not only in the inspector but via code as well. After looking through the docs and not really understanding how to make use of .any(), .all(), ....
2votes
2answers
135views
Generic Dynamic Array Implementation
I wrote a dynamic array implementation in ISO C11 using void pointers. Everything I've implemented works--at least in all my tests--on a 64-bit machine. It has some vague type-checking and resizes ...
1vote
0answers
67views
Presence of UB and memory usage of a std::array initialization: version with temporary array on heap
I proposed several techniques to answer to https://stackoverflow.com/q/78672409/21691539. A classical way to answer would be to use std::index_sequence-based ...
5votes
2answers
977views
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 ...