arrays

Variable-sized Array Initialization in Java

I have an array of integers in Java that is initialized as follows: public int MyNumbers[] = {0,0,0,0}; I would like to, however, initialize the array to a variable-length number of zeroes. private int number_of_elements = 4; public int MyNumbers[] = {0} * number_of_elements; // ???? I am clueless how to do this being new to Java ...

Sort Array by Key

I have two arrays used in a small game. If the player gets a score above a certain value their name & score gets output via an UILabel. NSArray *namesArray = [mainArray objectForKey:@"names"]; NSArray *highScoresArray = [mainArray objectForKey:@"scores"]; I need the UILabels to display with the highest score in descending order,...

How do you get a dimension of an Array as an Array from a 2D array?

I have this 2D array: Private _Chars As String(,) = {{"`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "="}, {"¬", "!", """", "£", "$", "%", "^", "&", "*", "(", ")", "_", "+"}} I want to Pass a Dimension (ie. the First Line) into a Function, or the Second Line into a function to switch be...

VB.net. Find the 2 lowest values in an array and remove them.

I have a simple array created for a Die roller. I want to roll 5 six sided dice, and remove the lowest 2 values. What code would help me do this. here is my basic code for the 5 dice Public Partial Class MainForm Public Sub New() Me.InitializeComponent() End Sub Sub Button1Click(sender As Object, e As EventArgs) Dim d61 a...

How do I put an array on the POE heap and push or pop data?

How do I put an array on the POE heap, and push/pop data to/from it? I'm trying to put the following array on the heap: @commands = ( ["quit",\&Harlie::Commands::do_quit,10], ["part",\&Harlie::Commands::do_part,10], ["join",\&Harlie::Commands::do_join,10], ["nick",\&Harlie::Commands::do_nick,10], ["module",\&Harlie:...

Do not understand how this array result happens

I'm trying to learn to build a login sequence. In one part, I wanted to determine if the user left any of the 3 required fields blank: foreach ( $_POST as $key => $value ) { if ( $key = "school_code" || $key = "user_name" || $key = "password" ) { if ( $value == "" ) ...

Working with Java arrays

/** * Testing Arrays * @author N002213F * @version 1.0 */ public class JavaArrays { public void processNames(String[] arg) { //-- patented method, stop, do not read ;) } public void test() { // works fine String[] names1 = new String[] { "Jane", "John" }; processNames(names1); /...

Retreiving data from an array PHP

Hi Guys, Im trying to get a value from an array used in the Joomla Plugin Hot Propertys. The array is stored in $this->properties inside that is group of arrays (sorted by number) and inside each one of them is a key called typeid. Basically i just need to get the typeid from one of those arrays (for example array 0) Ive tried $this-...

Access to elements of a multidimensional array, with a function

Hi, I need a function with variable number of arguments, to access to the elements of a multidimensional array. I have done in this way ($this->_config is the array)... function item() { if(func_num_args() != 0){ $config = $this->_config; $args = func_get_args(); foreach($args as $item){ $config =...

How to read from set of arrays line by line in Java?

Hello, My code is as follows: private static ArrayList<String[]> file; ... void method() { file = new ArrayList<String[]>(); ... String[] s = str.split(";"); file.add(s); } In the above, str is a long String that is seperated by semicolons. My problem is that I want to go through each array in the ArrayList and get one ele...

Heaps vs. Binary Trees - How to implement?

when implementing a heap structure, we can store the data in an array such that the children of the node at position i are at position 2i and 2i+1. my question is, why dont we use an array to represent binary search trees and instead we deal with pointers etc.? thanks ...

What is the most efficient way to place a list of drives in a ComboBox using C#?

I am creating a program that allows the user to select a drive letter from a combo box. I am debating between populating the box using a list or an array. What is the best and most efficient way to do this? ...

World nations on one php array, better if static?

I'm working on a site where the user can select his country, for now I've created an array which contains alla nation names and relative codes like it code for Italy: <?php $nations[] = array ("code" => "af", "name" => "Afghanistan"); $nations[] = array ("code" => "ax", "name" => "Aland Islands"); $nations[] = array ("code" => "al", "na...

How can i compare queues in cpp ?

hi there i need to compare the size of 10 queues and determine the least one in size to insert the next element in creating normal if statements will take A LOT of cases so is there any way to do it using a queue of queue for example or an array of queues ? note : i will need to compare my queues based on 2 separate things in 2 situat...

How do you initialise a dynamic array in C++?

How do I achieve the dynamic equivalent of this static array initialisation: char c[2] = {}; // Sets all members to '\0'; In other words, create a dynamic array with all values initialised to the termination character: char* c = new char[length]; // how do i amend this? ...

C++ memory leaks: are dynamically created arrays removed on leaving a function call?

So I have a function that creates a dynamic array, I then delete the array before I leave the function (as I thought I am supposed to), however I am getting a 'Heap Corruption Detected' warning in VS2008. If I remove the line that deallocates the memory everything works fine: void myFunc() { char* c = new char[length]; memset(c,...

are arrays in php passed by value or by reference?

When an array is passed as an argument to a method or function is it passed by reference? What about doing this: $a = $array(1,2,3); $b = $a Is $b a reference to $a? ...

MySQL Subgroup?

I'm still getting the hang of more advanced MySQL queries, so bear with me here... I have a table (1 table) with the following columns: name, source, destination, count I want to group my results by name, then subgroup them by the pairing between destination and source. So far all I have is this query: SELECT name, destination, sourc...

Storing arrays in MySQL?

On the Facebook FQL pages it shows the FQL table structure, here is a screenshot below to show some of it. You will notice that some items are an array, such as meeting_sex, meeting_for current_location. I am just curious, do you think they are storing this as an array in mysql or just returning it as one, from this data it really ma...

Is this the best code to use for reading from a networkstream (vb.net)?

I know it's subjective but this was the result I came up with based on the answer to me previous question and it seems a bit "slapped together", as I have changed it quite a bit: Private Function ReadFromBuffer(ByVal objReader As NetworkStream) As Byte() Dim intRead As Integer = 1024 Dim allBytes(-1) As Byte While intRead...