arrays

Java Applet - ArrayIndexOutOfBoundsException

OK so I am getting an ArrayIndexOutofBoundsException. I don't know why. Here's my code: /** Tile Generator Programmer: Dan J. Thanks to: g00se, pbl. Started May 23, 2010 **/ import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class tileGen extends Applet implements KeyListener { Image[] tiles; // tile...

linear combinations in python/numpy

greetings, I'm not sure if this is a dumb question or not. Lets say I have 3 numpy arrays, A1,A2,A3, and 3 floats, c1,c2,c3 and I'd like to evaluate B = A1*c1+ A2*c2+ A3*c3 will numpy compute this as for example, E1 = A1*c1 E2 = A2*c2 E3 = A3*c3 D1 = E1+E2 B = D1+E3 or is it more clever than that? In c++ I had a neat way to a...

Stupid newbie c++ two-dimensional array problem.

I've no idea if this is too newbie or generic for stackoverlflow. Apologies if that's the case, I don't intend to waste time. I've just started working through C++ Primer Plus and I've hit a little stump. This is probably super laughable but: const int MONTHS = 12; const int YEARS = 3; int sales[YEARS][MONTHS] = {0}; const string mont...

create a YYYY-MM-DD Daterange in JScript/Javascript.

Hello. I need no generate a full daterange in JScript from a given Startdate to now. Startdate: 2010-03-25 2010-03-26 2010-03-27 ... 2010-05-30 I am very confused with Javascript Date. best would be a function to give a daterange as params and getting an Array of the formatted date back, something like that: range[0] = 2010-03-25 ra...

Extracting [] elements from form collection - mvc - should use icollection but have mix of types

hi there. have looked at Phil Haacks project on books at http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx which has been useful, but I have a mix of data types. I use a modelview so that i can have a mix of objects, in this case: Order (ie order.id, order.date etc), Customer, SoilSamplingOrder and a list of SoilSam...

Array Recursion

I've got an assignment I can't figure out, any pointers will be much appreciated, it goes like so: There's a series of light bulbs represented as an array of true/false, there's a switch for every light bulb, by clicking it for any light bulb, you toggle it as well as 2 adjacent ones (1 from left & another 1 from right; if clicked switc...

Need to sort 3 arrays by one key array

I am trying to get 3 arrays sorted by one key array in objective c for the iphone, here is a example to help out... Array 1 Array 2 Array 3 Array 4 1 15 21 7 3 12 8 9 6 7 8 0 2 3 4 8 When sorted i...

How to turn bytearray into IList in Actionscript?

How to turn Array (like Camera.names) into IList (for for ex MXML s:DropDownList <s:DropDownList x="113" y="121" selectedIndex="0" dataProvider="{Camera.names}"></s:DropDownList> )? ...

Custom array sort in perl

I have a perl array of to-do tasks that looks like this: @todos = ( "1 (A) Complete online final @evm4700 t:2010-06-02", "3 Write thank-you t:2010-06-10", "4 (B) Clean t:2010-05-30", "5 Donate to LSF t:2010-06-02", "6 (A) t:2010-05-30 Pick up dry cleaning", "2 (C) Call Chris Johnson t:2010-06-01" ); That first number is th...

ArrayIndexOutOfBound exception even though I check for array length!

I have the following code in some app: int lowRange=50; int[] ageRangeIndividual = {6, 10, 18, 25, 45, 65, 90}; int index=0; for (; index<ageRangeIndividual.length-1 && ageRangeIndividual[index]<=lowRange;index++); I am getting an "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7" in the for line! even though I ...

MS Charts C# DataSource from array or List

i want to fill the data of the charts from values i have in 2D array, one column will present the X-axis and the second is present the Y-axis.. i did it, but its not reading from the array, it gives me the default line when i run the application, i found a solution using List<>, i had an error, so if any one could help me in this, i will...

0.00 decimal fields in MySQL database giving empty value when in a PHP array

The fields read as 0.00 in phpMyAdmin, but when put into an array, the value is blank, is there a way to get it to show just '0'? From my Model: $query = $this->db->query("SELECT t1.numberofbets, t1.profit, t2.seven_profit, t3.28profit, user.user_id, username, PASSWORD , email, balance, user.date_added, activation_code, activated FROM...

array_merge vs array_value for resetting array index

I have 1 array that I want to re-index. I have found that both array_values and array_merge functions can do the job (and I don't need 2 arrays for the array_merge function to work). Which is faster for a very large array? I would benchmark this, but I don't know how and don't have the large array yet. Before re-index: Array ( [0...

Sort the $_POST variables

Hello guys Might be an easy for you guys. I am trying to sort the $_POST variables that were sent by a form and update the sorted result in mysql. I am not sure how to do it and appreciate it anyone can help me about it. My main.php //I have a loop here. (omitted) //$k will be increased by 1 every time the loop starts, so I will kn...

Reading in a 5000 line text file on the Iphone

Gday, I am trying to create a tiled map for my game, i have had this previously working using other xml methods but i had memory leaks and all sorts of errors. However i had a map load time of about 2.5 - 3 seconds. So i rewrote all of the code using NSMutableStrings and NSStrings. After my best attempt at optomizing it i had a map load...

NSArray containObjects method

Hi, I have a simple question regarding xcode coding but don't know why things are not performing as I think. I have an array of objects (custom objects). I just want to check if this one is within the array. I used the following code: NSArray *collection = [[NSArray alloc] initWithObjects:A, B, C, nil]; //A, B, C are custom "Item" ob...

Trying to write priority queue in Java but getting "Exception in thread "main" java.lang.ClassCastException"

For my data structure class, I am trying to write a program that simulates a car wash and I want to give fancy cars a higher priority than regular ones using a priority queue. The problem I am having has something to do with Java not being able to type cast "Object" as an "ArrayQueue" (a simple FIFO implementation). What am I doing wrong...

How do I iterate over an Array field reflectively?

I have Class<? extends Object> class1 = obj.getClass(); Field[] fields = class1.getDeclaredFields(); for (Field aField : fields) { aField.setAccessible(true); if (aField.getType().isArray()) { for (?? vals : aField) { System.out.println(vals); } } } ...

php array clear

Is there any default function to clear only the values of an array. For ex arr{10,3,3,34,56,12} to arr{0,0,0,0,0,0} ...

Arithmetic Operations in Arrays with PHP

I have two arrays $data1 = array() $data1 = array( '10','22','30') and also another array carries $data2 = array() $data2 = array( '2','11','3'); I need to divide these two arrays(ie,$data1/$data2) and store value to $data3[]. I need to get it as follows $data3[] = array('5','2','10') If someone knows of an easy way to do this ...