Questions tagged [array]
An array is a systematic arrangement of similar objects, usually in rows and columns.
223 questions
1
vote
1
answer
67
views
Is there an idiom for specifying axes and dimensions of array(-like) parameters? [closed]
Many programming languages have functions which take a parameter which is a potentially-multi-dimensional array, where the number of axes and the dimension in each axis is not specified in code. This ...
0
votes
1
answer
186
views
Elegant way in C to store many parameters with default value and current value in embedded flash
I'm programming an embedded system that has a number of user configurable parameters, which are stored in flash memory. I have to store a default value for each parameter as well as the user settings. ...
0
votes
1
answer
541
views
Array structure for nested grouping (JavaScript)
I am currently struggling with how to solve nested grouping of data.
The initial structure is given and my grouped structure below as well as my approach can be adjusted.
My idea was to have the array ...
26
votes
6
answers
24k
views
How can Rust be "safer" and "faster" than C++ at the same time?
I have been told that Rust is both safer and faster than C++. If that is true, how can that be even possible? I mean, a safer language means that more code is written inside the compiler, right? More ...
-2
votes
3
answers
138
views
What are the pros and cons of different combinations of objects and arrays for data storing?
From the article JavaScript 2D Array – Two Dimensional Arrays in JS, I see one way to store data is to put all properties of each element into one array:
let dataRepresentation1 = [
['John Doe', ...
4
votes
4
answers
905
views
When should tuples be used as an argument instead of an array?
I hope this isn't too off-topic/opinion-based, I'm new here.
I want to pass three elements of the same type into a function. The three elements are unique cards of a deck of cards, so they're not ...
0
votes
4
answers
1k
views
What prevents Java from having immutable primitive arrays?
Java never had immutable primitive arrays. However Java does have an immutable List or Map or other collection classes and of course final primitive fields and variables. In Java if you try to make an ...
5
votes
2
answers
3k
views
Why does C not support direct array assignment?
In C you cannot assign arrays directly.
int array[4] = {1, 2, 3, 4};
int array_prime[4] = array; // Error
At first I thought this might because the C facilities were supposed to be implementable with ...
0
votes
3
answers
127
views
How multiple type lists are stored in memory?
Arrays are stored in a linear fashion, with memory cells of fixed size for each element. To have fixed sized memory cells Arrays should be homogenious. So in Arrays we get an Nth element by skipping ...
4
votes
2
answers
2k
views
Multidimensional vs nested arrays
A seemingly basic question here.
Is there anything you can do with multidimensional arrays that you can't do with nested arrays?
Many languages have been designed with both facilities and syntactical ...
0
votes
0
answers
57
views
JavaScript: My logic traversing multi-dimensional arrays
Consider the following:
Let's say below is the multi-dimensional, and you are given the starting point of [2, 2].
const WORLD = [
['P', 'P', 'P', 'C', 'P'],
['P', 'M', 'P', 'C', 'P'],
...
0
votes
0
answers
139
views
Best choice for a holding large number of objects in java
I have a set of array, containing a large number of objects (products), which has lately grown so large, searching in it takes about a minute, which is considered too long, since one search is ...
2
votes
2
answers
2k
views
JS - two array filters vs. one forEach?
I've had a question for a while. I know that the Array prototype method filter is generally preferred over forEach, and I believe it is typically faster at the job as well.
But what about if I have ...
2
votes
1
answer
2k
views
Do C++ compilers optimize/pack small data types (e.g. boolean values)?
This occurred to me when looking at stencil computations in numpy. This python library compiles compute-intensive components, so I believe that it's a valid example. Here making selections on an array ...
-2
votes
2
answers
1k
views
Comparing and replacing values in an array [closed]
I am currently working on a program that replaces the value in an array if the value next to it is the same as the current value. So If the array is [0,0,0,1,0,1,0], when the program runs it'll turn ...