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.

Filter by
Sorted by
Tagged with
1
vote
2answers
449 views

Improve speed of object-to-html transform in javascript?

I have a rather large javascript array of objects that I am transforming into an HTML table. Each object in the array looks like: ...
3
votes
1answer
196 views

Small class to manage config data

I made this small class the allows me to navigate large arrays using something like: key1/key2/key3 I made this because I was creating large arrays to hold my classes configs and needed a simpler way ...
4
votes
1answer
7k views

Routing in MVC with PHP

I am in the progress of creating a MVC structured website. I've opted to make my own instead of using pre-constructed MVC systems as a way to teach myself better coding and understanding how ...
1
vote
1answer
180 views

What specific optimizations can be made to this BitArray class, and how can they be implemented?

Here is the current code for the BitArray class needing optimization (implemented on big integers): ...
5
votes
2answers
912 views

How can I optimize this array.each in ruby?

I'm trying to optimize this bit of code and I thought I'd throw it out here to see if anyone has any ideas. I've been testing the performance using ...
1
vote
1answer
307 views

Extracting Multiple Associative arrays in PHP

...
30
votes
5answers
132k views

Modifying an array during a foreach loop [closed]

This question is always on my mind. I usually alter the array while looping through its keys, based on my gut feelings: ...
0
votes
3answers
2k views

Searching first non repeating character

The program finds the first non repeating character in a character array, array contains only small case letters. ...
2
votes
1answer
360 views

User data storage

I am writing my own website where users sign up. It then saves that data in an array. I want to know if this is effective or if there are better ways to do it. ...
6
votes
1answer
4k views

Find all single elements in an array

I am interested in printing all numbers that do not have a match in an array. Example: 1,3,4,5,3,4,5,5,6 result 1,5,6 Please ...
1
vote
1answer
2k views

Java generics, convert nested list to array

I have to interface to some old code using nested arrays, so I have to convert my nested Lists to nested arrays. Any idea, suggestions, improvements are warmly welcomed. ...
2
votes
1answer
35 views

Find the object that contains title1-2

I use jQuery and underscore.js, I have title1-2 and I would like to have the action corresponding. ...
7
votes
5answers
13k views

Comparing string arrays

My code does what I need it to do, but I think I am missing the "right" way to do this with comparing the arrays. Essentially what I need this to do is compare a textbox entry against two different ...
1
vote
1answer
695 views

Downsampling boundaries of a 2D array

I have a linearized 2D array u (block_height * block_width) containing the values of a physical quantity over a regular 2D mesh. ...
0
votes
2answers
126 views

Help me condense a series of lengthy javascript conditional arrays

I'm not too used to working with arrays in javascript, so was wondering if there is a good way to condense this down. Any pointers much appreciated! you can see it in action @ http://www....
1
vote
1answer
6k views

PHP Add Column to two dimentional array

i do have two dimentional array of data in php. I do want to add another column with constant to that array for passing tabular data to next program. i am iterating and adding manually. What can ...
3
votes
1answer
3k views

Looping through arrays in VBA

I supplied the following code as an answer to this question on SO, but I was wondering if there was a better way to write out all those array loops (i.e. perhaps using a Collection/Dictionary?) It ...
19
votes
8answers
49k views

Java function to read a CSV file

I have a java function that reads a csv and returns its content as a Vector<Vector<String>>. The function seems to work as I need it, but my gut ...
8
votes
4answers
2k views

Creating a 2D array of map tiles

I am a C++ programmer new to Ruby and someone suggested that I post my code here since it doesn't quite match Ruby standards. Is there a more Ruby way of doing this? I have created a 2D array full of ...
1
vote
3answers
4k views

Optimize Array.indexOf

How can I optimize checking a value in recursion before operating on it? I'm using Array.indexOf (this is Javascript) ...
7
votes
4answers
16k views

Finding the Intersection of Arrays

I would like any advice on how to improve this code. To clarify what this code considers an intersection to be, the intersection of [3,3,4,6,7] and [3,3,3,6,7] is [3,6,7]. I would appreciate any ...
3
votes
2answers
4k views

Mutlilevel page list in CodeIgniter

I'm newly working with CodeIgniter and PHP. I wrote a category structured 'pages' code with listing pages as multilevel list or indented select box. ...
1
vote
1answer
2k views

Function to create an array of images

I guess I made the mistake of creating UIImage *image1 to UIImage *image11. Can an one advise me on how to improve it? ...
-1
votes
1answer
414 views

PSEUDO Query (jQuery extension) [closed]

I just invented PSEUDO Query! ...
2
votes
1answer
139 views

Setting configuration arrays

I've created a website that displays weather and currency rates for London and New York. The following is an abstract from my cityConfig.php script. Is this a ...
5
votes
1answer
3k views

Rearrange elements in two-dimensional array spiral order

Recently I was asked to write algorithm to rearrange elements in two-dimensional array in spiral order. Input array: Output array: ...
3
votes
1answer
472 views

JavaScript shuffle idea

Based on the standard implementation of Array.sort in JavaScript, would the following be a reasonable way of shuffling the contents of an array? Is it moderately ...
2
votes
1answer
1k views

RungeKutta method in C, pointers and arrays

Now the program works, but is it correct? Sometimes it works in C anyway. Could I improve it somehow (not numerically, just C-wise)? I need to allocate the array as I do right? Since I am returning it ...
2
votes
2answers
931 views

Javascript querystring to object conversion

The below code converts the window.location.search querystring into a JavaScript object. In particular, if a key occurs more than once the resulting value in the object will be an array. Please feel ...
7
votes
4answers
15k views

Getting the largest element in an array using recursion

Any suggestions on how to make this code more efficient? ...
5
votes
1answer
733 views

How should I efficiently delete elements from a PHP array?

In this case I have an array that is parsed from a JSON file. Normally I use all the elements in the array, but for AJAX crawling I only show the parts the search engine asked for: ...
3
votes
2answers
223 views

PHP Validation with functions and list()

I have multiple form validation checks around my site so I decided to write them as functions to simplify the process of creating the validation pages, here is a snippet for an understanding of what I'...
7
votes
2answers
389 views

Dynamic array container

This is primarily a container for quicksort and mergesort: ...
6
votes
1answer
393 views

Merging two array of classes

I have this function that should merge two array of classes when id of array1 is equal to id of array2. For simplicity I ...
3
votes
2answers
2k views

Checking if two byte arrays are the same

I have a method to compare two byte arrays. The code is Java-style, and there are many if-elses. ...
3
votes
3answers
5k views

Improving the code to turn a string into an array of numbers?

I have a string of numbers, like "31654918562314", and I want to convert it into an array of integers. The code I've written is: ...
4
votes
2answers
199 views

Array initialization from text string

I have a block of text where several arrays are printed out, with a name and values: VAL1=10 20 30 40 50 VAL2=4 8 15 16 23 42 I have a function that looks for the value name, and sets an ...
13
votes
3answers
23k views

Min / Max function of 1D array in C / C++

Due to software constraints, I cannot use the standard libraries, <math.h>, <algorithm>, templates, ...
1
vote
2answers
4k views

Php INSERT class function

This is a INSERT function. It's working... I just pulled out the function from the class, atm to try it out. And improve. I think the code is a bit messy, And I am pretty sure I can improve the code, ...
3
votes
1answer
552 views

Getting an array from one property of an associative array best practice

I have an array of objects eg. [ array( 'id' => 1, 'name' => "simon" ), ... ] and I need to get an array of IDs eg. [1,2,3,4,5]; Currently I'm doing this: ...
5
votes
3answers
4k views

Split post string into hash

...
5
votes
1answer
170 views

Ruby: working with arrays

I am working on a script that collects all comments from my DB and inserts them into a hash. I then do a collect on the comments hash and split the comments into two separate comment hashes (...
7
votes
4answers
7k views

Simple array implementation without bounds-checking

I am preparing myself for some job interviews. This is a simple array (with the error handling left out for brevity). Any input or suggestions on style and the use of templates would be appreciated. <...
2
votes
2answers
1k views

Rolling loop with an array of data points

I have a NumPy array of about 2500 data points. This function is called on a rolling basis where 363 data points is passed at a time. ...
4
votes
2answers
845 views

Remove repeated words from a 2D character array

This code removes repeated words from a word array (2D char array). I want to optimize this as much possible for speed. ...
6
votes
1answer
5k views

Combining 3 or more arrays in php

Assuming I have 5 arrays, all just indexed arrays, and I would like to combine them, this is the best way I can figure, has anyone found a more efficient solution? ...
1
vote
3answers
4k views

Multiline Input into Python Arrays

I've knocked together a few lines of python to read in stats for a service (haproxy), and store them in an array (to do some analysis on later). It basically takes a multiline output, and splits it ...
2
votes
1answer
9k views

What value the rear and front counter of an Array implementation of Queue start with? -1 or 0 or 1?

Is there anything wrong with this implementation of Queue with array? I have started front = rear = -1. Some references tend to start front = 0 like this:enter link description here I think if ...
8
votes
2answers
1k views

C-style array class

I often use C API's in C++ that force me to use C-style arrays. I got sick of constantly using a dynamic vector with &vec[0], so I wrote this C-style array ...
3
votes
1answer
3k views

Shuffling a JSON array in Java

Since I did not get a satisfactory answer here (and I really needed to get it going on this weekend), I decided to implement my own Fisher–Yates shuffle, porting the code I found in other SO posts. I ...