Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [array]

An array is a systematic arrangement of similar objects, usually in rows and columns.

Filter by
Sorted by
Tagged with
16 votes
10 answers
5k views

I have noticed in documentation, looking at open-source code bases, and just a general sense in the industry that C# developers largely prefer to use List<> or IEnumerable<> over simple ...
K0D4's user avatar
  • 423
1 vote
1 answer
84 views

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 ...
einpoklum's user avatar
  • 2,808
0 votes
1 answer
242 views

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. ...
jusaca's user avatar
  • 175
0 votes
1 answer
625 views

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 ...
Dollique's user avatar
  • 101
27 votes
6 answers
28k views

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 ...
euraad's user avatar
  • 403
-2 votes
3 answers
158 views

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', ...
Ooker's user avatar
  • 335
4 votes
4 answers
1k views

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 ...
dve.exe's user avatar
  • 59
0 votes
4 answers
2k views

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 ...
CPlus's user avatar
  • 1,219
7 votes
2 answers
4k views

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 ...
CPlus's user avatar
  • 1,219
0 votes
3 answers
163 views

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 ...
forty5's user avatar
  • 39
4 votes
2 answers
2k views

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 ...
Steve's user avatar
  • 12.6k
0 votes
0 answers
63 views

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'], ...
Antonio Pavicevac-Ortiz's user avatar
0 votes
0 answers
166 views

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 ...
kry's user avatar
  • 101
2 votes
2 answers
3k views

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 ...
Michael Jay's user avatar
2 votes
1 answer
2k views

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 ...
Daniel Krajnik's user avatar
-2 votes
2 answers
1k views

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 ...
Y3LLZ's user avatar
  • 13
4 votes
2 answers
1k views

I've been finding that for a lot of code I've been writing recently, it naively might look like this: Array approach: const options = [ { id: 'red', label: 'Red', data: '#f00' ...
dwjohnston's user avatar
  • 2,769
8 votes
8 answers
9k views

I am looking to understand the difference between the words index and offset. I have never seen "offset" in reference to lists/arrays/etc in programming. I have only seen index. To me, these ...
sudo pkill depression's user avatar
0 votes
1 answer
136 views

I have a function which has discrete time step ,discrete length from origin . These two give height of the function. For example at time 1.2sec , and length 5.5cm from origin height is 10cm. The step ...
Mokka Naresh's user avatar
-4 votes
1 answer
448 views

When teaching students Python lists (which are more like arrays, not linked-lists) I'd like to use metaphor of list being a collection of boxes put in row. But this doesn't work well: indexes are ...
danbst's user avatar
  • 93
8 votes
2 answers
7k views

Sorting is generally used to solve problems where distance between elements matters. A sorted list/array has the convenient property that the smaller the difference between the indices of any two ...
TheEnvironmentalist's user avatar
0 votes
3 answers
1k views

I would like to have IDs of different sizes from the alphabet 0-9. So I have 5-length IDs as in 10000 or 13531, etc.. I have 10, 15, 20, up to 39 digit strings (the size of a UUID). I would like to ...
Lance Pollard's user avatar
-2 votes
1 answer
129 views

When I was study lvalue i see that C expression can be lvalue if a subscript ([]) expression that does not evaluate to an array. (from https://docs.microsoft.com/en-us/cpp/c-language/l-value-and-r-...
Ulaş Sezgin's user avatar
3 votes
1 answer
432 views

Recently I was asked to refactor some code that leverages JavaScript's array.reduce() method because other developers felt the code hard to read. While doing this I decided to play around with some ...
Kenneth Moore's user avatar
2 votes
2 answers
764 views

I'm trying to understand why sizeof(a)/sizeof(t) is inferior for getting the length of an array to sizeof(a)/sizeof(a[0]) if just as it's possible to have different types, my elements could also be of ...
Farah Kamal's user avatar
-2 votes
1 answer
3k views

I need to generate a large Excel file (something around 50 megs) and send response to another API which will provide it to the front end for a download option. My question is if it will be better to ...
JackTheKnife's user avatar
1 vote
1 answer
515 views

I am currently writing a Python program that retrieves the pixels from two BMP files and finds the percent difference between them (without using the Pillow library for the purpose of learning). I can ...
8ask714's user avatar
  • 23
-2 votes
1 answer
3k views

In the domain of system-modeling (e, systemVerilog, matlab, phyton), lists are obsoleting arrays, stacks and queues(*) altogether. Other domains that use python, perl and ruby have that same mindset, ...
jsonphy's user avatar
  • 57
1 vote
3 answers
555 views

Array := {"title": "Book Title", "author": "John Doe"} Some people use the following terminology: title and author are keys. Book Title and John Doe are values. "title": "Book Title" and "author": "...
john c. j.'s user avatar
-1 votes
1 answer
114 views

Where would I begin if I wanted to develop an algorithm that maps consecutive whole numbers to a long list of unique sets of whole numbers. For example: 0 = {0, 0, 0} 1 = {0, 0, 1} 2 = {0, 0, 2} ...
comp1201's user avatar
  • 111
1 vote
1 answer
69 views

I have an array of objects and I'm trying to see, through each request, whether or not a new member appeared in my collection. The way I currently do it is, I require each member of the collection to ...
coolpasta's user avatar
  • 657
1 vote
3 answers
3k views

If I write this code in a function: void func(void) { int x = 0; int y = 3724832+x; } It would (probably) optimize the variable y out because it isn't being used. Even if I'm wrong about this ...
user avatar
1 vote
1 answer
677 views

I need to share some associative data between different parts of my application with two requirements: immutability (so read-only) safety against mispelling or unavailable index inside the data mixed ...
Sir_Faenor's user avatar
2 votes
2 answers
104 views

I've developed a reading tracking app in Swift and for simplicity's sake I used arrays for my model. It stores some data about the books a user reads and a small image of the cover. I save them to ...
M. Chollar's user avatar
1 vote
0 answers
43 views

I wasn't sure exactly how to word this question, but basically, I have a struct stNeuralLayers (for a neural network I'm playing around with) with fields that are matrices (such as a double[,] ...
Tara's user avatar
  • 151
0 votes
2 answers
519 views

Just a general programming best practices question. If I have a function like that takes in an array of items and the function then calls a series of other functions which filter and act on the items ...
dalold's user avatar
  • 11
2 votes
1 answer
2k views

for example, sometimes I need to define a hardcoded string with some variable parts, I often have trouble to choose the style: style 1 : reuse every characters when possible showMessage(num){ let ...
ocomfd's user avatar
  • 5,760
2 votes
2 answers
548 views

for example, Suppose I have a 2d array: let filterArr=[ [1,1,0,1,1], [0,1,1,1,0], [1,1,0,1,0] ]; I want to find and store the index of column that all are 1, i.e.:position 1 and 3, and the ...
ocomfd's user avatar
  • 5,760
0 votes
1 answer
169 views

For example, I have a toggle button, which would show the current selected element, and would show next element when it is clicked, and it can loop back to first element. I have 2 ways to store the ...
ocomfd's user avatar
  • 5,760
2 votes
2 answers
202 views

For example, suppose I have 2 arrays: let arr1=[5,2,1]; let arr2=["abcde","ab","a"]; my work is simple : to check if length of strings in arr2 are larger than corresponding element with same index in ...
ocomfd's user avatar
  • 5,760
3 votes
2 answers
141 views

For example, I have a for loop, which element 0 has additional function to run compared with other elements, my question is, should the additional function be: 1.place inside for loop for(int i=0;i&...
ocomfd's user avatar
  • 5,760
2 votes
3 answers
4k views

I have two classes called Player and Enemy both inheriting from a class called GameObject, how do I store them both in an array of type GameObject while still keeping their own unique information? I ...
Thomas Linssen's user avatar
3 votes
1 answer
159 views

I'm developing an application which sends quotes to clients via email. Since quotes are obtained from various resources (per each client) they end up in a single array which is then used as a source ...
Jan Richter's user avatar
-1 votes
2 answers
1k views

In C if i declare int x[4] Which tells me its an integer array with each array element size fixed of size 4. So after initialization when I access x[3] : address of array +element size which is 2 * ...
Mohan Pierce's user avatar
1 vote
2 answers
178 views

If you have a linked-list, where the items are not necessarily close to each other in memory, wondering if it is (in general) better/worse/no difference to do the following. Say you want to iterate ...
Lance Pollard's user avatar
3 votes
1 answer
355 views

I have a set of data: id | name | parentid ------------------------ 1 | parent | 0 2 | child | 1 3 | child | 1 4 | parent | 0 5 | child | 4 6 | subchild | 5 7 | child | 4 ...
amflare's user avatar
  • 241
4 votes
2 answers
6k views

I only know that index is faster but don't know why is it faster. Suppose I have an array int[] a = {2,3,6,7}. Then I will try to find the element at a[3] and the speed of this will be O(1). Why? How ...
Asif Mushtaq's user avatar
12 votes
2 answers
2k views

Many programming language use the syntax a[i] to refer to the i'th element of an array, sequence, or vector a - specifically, C and Pascal (from the late 1960s and early 1970s) do this. On the other ...
einpoklum's user avatar
  • 2,808
1 vote
2 answers
665 views

I've been thinking about this over the past few weeks, and I've come up with no good arguments. My perspective is from Java, but if anyone has any language-specific cases outside of this language, I'...
ndm13's user avatar
  • 229
3 votes
4 answers
137 views

Assume I have some data a csv-Files like ObjectName, PropertyA, PropertyB, PropertyC "Name1", 3, 1, 4 "Name2", 1, 5, 9 "Name3", 2, 6, 5 ... and a typical question I want to answer would be For ...
Elvorfirilmathredia's user avatar

1
2 3 4 5