Questions tagged [arrays]

77062 questions
0

votes
2

answer
35

Views

how to convert an array of integers (1s and 0s) to their ascii equivalents in c#

I have an array of integer 1s and 0s (possibly need to get converted to byte type?). I have used an online ASCII to binary generator to get the equivalent binary of this 6 digit letter sequence: abcdef should equal 011000010110001001100011011001000110010101100110 in binary. So in c#, my array is [0,...
mheavers
0

votes
3

answer
22

Views

Find a property (which is stored as a string in a variable) in an array of objects

I have an array of objects which store the data of different 'pupils'. var pupils = [ { id: 0, name: 'will' }, { id: 1, name: 'megan' } ]; I want to create a function called 'findPupil' which takes three parameters: the property you know, the value you know it to be and the property you want to find...
Gerard Way
0

votes
1

answer
29

Views

Duplicates search in array using HashSet and Brute Force

I am just trying a simple program on finding duplicates in given array. /* Using HashSet */ int[] arrays = {1,2,4,5,4,2}; Set hs = new HashSet(); for(int ar:arrays) { if(!hs.add(ar)) { System.out.println("Dupicate is:" +ar); } } /* Nested for loop */ int arraySearch[]...
Furkhundah Wali
1

votes
0

answer
11

Views

Pass Image to another function within same class

I've been searching for a solution for three days now. If everyone has an Idea please help me, I don't even think it's actually that difficult to achieve but It's not really my branch, if you can say it like this. In a RecyclerView containing a list with multiple Items, each having a Title(TextView)...
Shade Reogen
1

votes
1

answer
96

Views

Extracting an array of a member variable from a vector

Let's say I have a struct: struct Foo { float A; float B; float C; }; And I have a vector of the struct: std::vector vFoo; And a function that takes arrays of floats (or whatever the same type as Foo members): float foo_floats(const float a[], const float b[], const float c[]); My question is, is th...
Ernest Sato
1

votes
3

answer
2.7k

Views

Difference between multi dimensional arrays and array of pointers

I always believed that in C : int a[5][3]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; refers to an array of arrays and in memory fifteen contiguous blocks are stored but a[0] is the pointer to a[0][0] and a[1] is the pointer to a[1][0] and so on. So I thought it to be similar to be an array of pointers....
user1369975
1

votes
1

answer
3.4k

Views

SystemVerilog packed array vs unpacked array memory footprint

Is it true that with the contemporary advanced SV RTL simulators, the simulation footprint may increase when using unpacked arrays vs the packed arrays? If so, is this a problem and do verification teams insist on rules to use packed arrays? TIA. Sanjay
shparekh
1

votes
1

answer
2.5k

Views

Unable to index into an array to turn it into a hash table

I am trying to convert an array into a hashtable but I keep getting this error Unable to index into an object of type System.Management.Automation.PSObject. I have searched everywhere and could not find others having the same problem. My code: [array]$compArray = $ds3 | select -Property DeviceName,...
JasonBluefire
1

votes
1

answer
3.8k

Views

Numpy array: concatenate arrays and integers

In my Python program I concatenate several integers and an array. It would be intuitive if this would work: x,y,z = 1,2,np.array([3,3,3]) np.concatenate((x,y,z)) However, instead all ints have to be converted to np.arrays: x,y,z = 1,2,np.array([3,3,3]) np.concatenate((np.array([x]),np.array([y]),z))...
Forzaa
1

votes
3

answer
192

Views

PHP Array issue when trying to auto select dropdown

Note: $i is set earlier in the code and there are 25 drop down boxes, the array shows the first 5 have values, so I need to set those drop downs to selected and show the relevant value. I have an array that contains the following: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => [6] => [7...
Homer_J
1

votes
3

answer
2.7k

Views

For Loop Inside Switch Statement in PHP

I have certain ranges saved in array with price at index [3] and discount type at index [4] (%, fixed). Anyone buying within those ranges should get available discount. My Current Problem is range of an array could be of any count, for example here in variable $a, there is 4 nested array, but in ce...
Johny Bravo
1

votes
2

answer
205

Views

Add relativelayout programmatically

I have the following XML: As you can see above, there is a repeat of the same code (From ImageView to and this is just an example. I have to repeat it 41 times, instead of 3 that is shown here. Instead of using XML how do I add it programmatically (Let's say tvDate and tvReason are String arrays)?...
Si8
1

votes
3

answer
102

Views

beginner java - printing tables

I'm printing values from 0-99 and a random string from food array. I can't seem to output them to a table correctly. String foods[] = {"Bread", "Pizza", "Cheese"}; for (int x = 0; x
danieljohngomez
1

votes
5

answer
168

Views

About sorting array list

I am trying to ensure that the objects i insert in productDatabase have not been already inserted and that i sort my arraylist using method sortData but without using any comparators in method sortData public class Application { public static void main(String[] args) { Product p = new Product(15,"t...
CurrentLer
1

votes
1

answer
440

Views

Creat a dynamic Loop in VBA with array

I want to create a loop for time series in VBA , so that the LINEST would be done in every row, data for LINEST have to be dynamic, e.g. =Linest(C6:N6; Q1:AB2; TRUE) ==> result array of thre next row =Linest(C7:N7; Q1:AB2; TRUE) ==> result array of three next row =Linest(C8:N8; Q1:AB2; TRUE) ==> res...
user2983871
-1

votes
1

answer
44

Views

Parse JSON result with Attributes

Inside a decoded JSON I have also a sub list with: "steps": [{ "id": 54785, "response": { "attributes": { "xsi:type”:”text1”},”message": { "attributes": { "xsi:type": "xsd:string" }, "$value": "alterMultipleParameter" }, "nextcase": { "attributes": { "xsi:type": "xsd:int" }, "$value": 4823 }...
Ingo
0

votes
3

answer
39

Views

How copy an array's contents into two smaller arrays of unequal size

I am trying to copy contents of a larger array to two smaller arrays of an unequal size each (of which size may change according to the program). I have four arrays at the simplified code below: #define size 20 double bigArray[size]={14.553,13.653,9.555,8.564..and so on...9.324,11.123}; /*IndicatorA...
Yannis Dran
0

votes
2

answer
23

Views

Map comments from Twitch API - React

I'm having trouble mapping comments / results from a Twitch API. I'm getting a TypeError when I try to map, and the results being stored from the API are capping at 60 records, and I cannot find a way to keep mapping past that. Below is my Component that is handling the API call and mapping... impo...
Tyler Watts
0

votes
0

answer
2

Views

Logstash nested object in nested object

I want to add nested object in a nested object. Here's my logstash conf. filter{ mutate { add_field => { "taskId" => "bx-%{box_id}" } } aggregate { task_id => "%{taskId}" code => " map['box_posts'] ||= [] map['post_media'] ||= [] map['box_posts'] event.get('post_box_id'), 'score' => event.get('sc...
23abc443
1

votes
3

answer
4.6k

Views

Wordpress Get unique custom field values in a list

I have a whole list of directors but would like to display only their unique names not duplicates. Something that looks like director A, Director B, Director C,... NOT director A, Director A, Director B, Director C, Director C,... I try to do this with array_unique but it doesn't seem to put any dat...
Phil
1

votes
2

answer
8.1k

Views

using grid view and image View to display some images

i am creating a simple android application that will display several images and on the selected one the system will display it in the image view .. but the problem is that the system display the id of the images than on the select of specific image the system display the image in the image view ....
user3006788
1

votes
3

answer
94

Views

My c++ function is destroying variables when it shouldn't be

The purpose of this function is to take a struct, and enlarge the array by 1. It does this by copying the array to a temporary array, deleting and recreating the original with a larger size. My problem is that when I run the function, all of my values within the struct become '-17891602'. Correct me...
1

votes
1

answer
40

Views

replacing a particular number of an array by the number of that position of another array

I am trying to write a function to replace a particular number of an array by the number of that position of another array. However, it does not allow me to do so. I am quite new in using MATLAB. Any help will be appreciated. arr1 = [ 1 3 8 9 2 47 10 4 2 4 6 86 6...
user3226108
1

votes
3

answer
5.1k

Views

Delete Row from Array

I am trying to go through an array to find duplicate entries in a single column of that array and delete the entire row. I am getting figuring out rangeStart, rangeEnd, and lastrow above this and that part is working fine. data = Range(rangeStart, rangeEnd) For i = lastrow - 1 To 2 Step -1 If data(...
CongdonJL
1

votes
1

answer
490

Views

numpy array split/partition efficiency

This appears to be a simple issue, but I've been struggling trying to efficiently split a 2D array: start_time = time.time() M = np.ones((400,400)) for i in range(10000): e = np.array_split(M, 20) print time.time() - start_time However, this process takes ~6 seconds comparing to ~0.5 seconds when im...
neither-nor
1

votes
1

answer
170

Views

Perl: Delete keys in hash that don't exist as elements in array

I have an array of key names and need to remove any keys that are not in this list from a hash. I gather deleting keys in a hash is a Bad Thing while iterating over it, but it does seem to work: use strict; use warnings; use Data::Dumper; my @array=('item1', 'item3'); my %hash=(item1 => 'test 1', it...
Tim Jones
1

votes
1

answer
74

Views

How to pass 2d array into c program?

newUpdate: seems to work now updated: OK, so this is my declared 2d array: int data[10][20]; It's filled up with variables as such: k=0; token = strtok (str," "); while (token != NULL) { sscanf (token, "%d", &var); data[k++][i] = var; token = strtok (NULL," "); } So we expect data[0-9][i] for each...
user3251142
1

votes
2

answer
1.5k

Views

Summing over first 2D of 3D matrix

Suppose I have a 3D matrix A of size (1,2,3). Something like A(:,:,1) = [1 2] A(:,:,2) = [3 4] A(:,:,3) = [5 6] How would I go about finding the 3 values that make up the sum of the first two dimensions, for example. sum(A(:,:,1) = 3 The above works, but when I try it for an array with larger dime...
EMChamp
1

votes
3

answer
51

Views

Removing empty elements from php array

Im looking for a way to remove empty elements from an array. Im aware of array_filter() which removes all empty values. The thing is that i consider a string containing nothing but spaces, tabs and newlines also to be empty. So what is best used in this case?
0

votes
0

answer
18

Views

Problem with Multidimensional array in vuejs

Multidimensional Arrays Event Table We have multiple objects, inside each object we have got arrays and each array have objects.[Multidimensional Arrays] We want to check if problem.user_id is exist in users.id(current logged in user) If it does then button will be disabled and if it doesn't then i...
Anirban Roy
0

votes
0

answer
18

Views

Clarification on how Stacks are implemented through Objects in Java?

So I have a basic stack implementation here using an interface in Java and I had a couple of questions on how all this works, public class ArrayStack implements ArrayStackADT { private T[] ArrayStack; private int top; public ArrayStack() { ArrayStack = (T[]) new Object[20]; } So I do understand that...
CosmicCat
0

votes
0

answer
16

Views

How to Print Possible permutations of the Array length in java

I'm working on task in which i have to show the possible permutations of the length of array. I've tried some tricks but it's still giving the list of many outputs, and in the end my project get crash. I've tried mathematically and i got answer "39916800. For example: For input array [3,2,1,4,6], t...
Umer Waqas
1

votes
5

answer
5.1k

Views

Ranking/Position on value of array in PHP

I have an array with these values, Array ( [0] => 12 [1] => 17 [2] => 5 [3] => 27 [4] => 5 ) and I need to find out ranking/position of each value ie, for 27 - Rank 1 for 17 - Rank 2 for 12 - Rank 3 for 5 - Rank 4 for 5 - Rank 4 (duplicate value in the array) and these need to be in the same o...
Kiran Kumar
1

votes
1

answer
812

Views

If I use “array.splice()”, are the removed elements deleted from memory?

I'm writing some functions to remove elements from arrays. I'm using splice for this, and it is working just fine. However, I am not 100% sure as to whether or not splice completely removes the removed elements from memory, or if they are still instantiated somewhere that I am unaware of. Does anybo...
thisissami
1

votes
1

answer
646

Views

Nullpointer Exception when assigning value to Integer array

This seems a bit strange to me. I created a static Integer array and then I am trying to assign a value to it. But I get a Null pointer exception at the degree[i] = 0 line. Since I am not reading the value before assigning it, I do not understand why the NullPointer exception. private static Integ...
Yathi
1

votes
1

answer
89

Views

why javascript splice called splice even though it doesn't join but splits the array

JavaScript splice method actually splits an array into two as shown in the below example: var a = ['a','b','c']; var b = a.splice(0,2); console.log(a); // outputs ['c'] console.log(b); // outputs ['a'.'b'] Then why is it called splice since splice means to join
iJade
1

votes
2

answer
53

Views

How to limit an array of similar hashes to those that have more than one of the same key:value pair (details inside)

I have an array like this arr = [ { name: "Josh", grade: 90 }, {name: "Josh", grade: 70 }, { name: "Kevin", grade: 100 }, { name: "Kevin", grade: 95 }, { name: "Ben", grade: 90 }, { name: "Rod", grade: 90 }, { name: "Rod", grade: 70 }, { name: "Jack", grade: 60 } ] I would like Ben and Jack to be...
JoshEmory
1

votes
5

answer
79

Views

Create multidimensional arrays using single table

I have a table like this; **Year** **Month** 2012 Jan 2012 Mar 2012 Apr 2013 Dec 2013 Nov And I am trying to create an array from this table similar to below; Array ( [2012] => Array( Jan, Mar, Apr), [2013] => Array( Dec, Nov) ); so far I tried this code, but di...
user3289328
1

votes
2

answer
209

Views

NumPy map calculation depending on the indices

I have a NumPy array of shape (Height, Width). Now I want to calculate the value of all the elements present in this array. The value is a function of the position [x,y] of the element. Suppose I want to assign all the elements the value as (x**2+y**2)/2. I want to do this without using a for loop....
chaithu
1

votes
1

answer
980

Views

Android bold text in String-Array

I need to bold some text in a String Array, where each item is being used in a ViewPager. I am using getTextArray() to grab the formatted text from the xml file, and cannot cast that into a String to be able to be used in the ViewPager. This is what I recently tried, but it stripped the formatting:...
user3479104

View additional questions