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
0
votes
0
answers
18
views
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 ...
6
votes
7
answers
1k
views
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 ...
2
votes
1
answer
33
views
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 ...
3
votes
1
answer
97
views
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:
...
1
vote
2
answers
387
views
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 ...
3
votes
1
answer
91
views
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 ...
6
votes
3
answers
333
views
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,...
7
votes
3
answers
990
views
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 ...
3
votes
2
answers
86
views
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 ...
3
votes
2
answers
145
views
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 ...
3
votes
0
answers
98
views
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. ...
0
votes
0
answers
33
views
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(), ....
2
votes
2
answers
135
views
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 ...
1
vote
0
answers
67
views
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 ...
5
votes
2
answers
977
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 ...