arrays

How does array class work in Java?

In Java, array is a class and extends Object. I am curious to know about this special array class. I don't find the class definition anywhere. Doing a getClass().getName() gives strange result. String[] array = new String[]{"one","two"}; System.out.println(array.getClass().getName()); // prints [Ljava.lang.String; I want to understand...

Problem in getting multidimensional array from simple xml object

Hi there, As a newbie I need your help in getting multidimensional array from simplexml object. suppose my array is like: just for getting idea: Here $data is a simplexml object contains below xml: <users> <user> <id></id> <nm></nm> <gender> <male></male> <female></female> </gender> </user> </users> ...

jQuery arrays - newbie needs a kick start

I've only really started using this site and alredy I am very impressed by the community here! This is my third question in less than three days. Hopefully I'll be able to start answering questions soon instead of just asking them! I'm fairly new to jQuery and can't find a decent tutorial on Arrays. I'd like to be able to create an arra...

Strange realloc behaviour

Hi guys, i'm developing an array structure just for fun. This structure, generalized by a template parameter, pre allocates a given number of items at startup, then, if "busy" items are more than available ones, a function will realloc the inner buffer . The testing code is : #include <stdio.h> #include <stdlib.h> #include <string.h> t...

PostgreSQL multidimensional array search

Hi Guys, I am a newbie to Postgresql and was trying with it. I have created a simple table: CREATE table items_tags ( ut_id SERIAL Primary KEY, item_id integer, item_tags_weights text[] ); where: item_id - Item Id with these tags are associated item_tags_weights - Tags associa...

About conversion of simplexmlobject to array.

Hi guys, I tried the way you told but really messing up on some points. I am getting array fields but when it comes to children nodes, i go off the track. here giving single user's simplexml object only : SimpleXMLElement Object ( [users] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => array ) [user] => Array ( [0] =...

How do I increment a DOS variable in a FOR /F loop?

I'm trying to read text lines from a file, and increment a counter so I can eventually simulate an array in DOS. I'd like to be able to store the lines of text in a DOS array for further processing. My current attempt is: set TEXT_T="myfile.txt" set /a c=1 FOR /F "tokens=1 usebackq" %%i in (%TEXT_T%) do ( set /a c=c+1 echo %%i, %c%...

Resizing a rectangular array

Does a smarter way than the following exist to resize a rectangular array? double[,] temp = new double[newSize, originalSecondDimension]; Array.Copy(original, temp, original.Length); I was concerned about duplicating a huge array and the memory necessary to do it. What does the Array.Resize() do internally? Thanks, Alberto ...

How to create extensible dynamic array in Java without using pre-made classes?

Yeah, it's a homework question, so givemetehkodezplsthx! :) Anyway, here's what I need to do: I need to have a class which will have among its attributes array of objects of another class. The proper way to do this in my opinion would be to use something like LinkedList, Vector or similar. Unfortunately, last time I did that, I got fire...

javascript - Google Chrome cluttering Array generated from .split()

Given the following string: var str = "one,two,three"; If I split the string on the commas, I normally get an array, as expected: var arr = str.split(/\s*,\s*/); Trouble is that in Google Chrome (for Mac), it appends extra properties to the array. Output from Chrome's debugger: arr: Array 0: one 1: two 2: three co...

seg fault caused by malloc and sscanf in a function

Hi, I want to open a text file (see below), read the first int in every line and store it in an array, but I get an segmentation fault. I got rid of all gcc warnings, I read through several tutorials I found on the net and searched stackoverflow for solutions, but I could't make out, what I am doing wrong. It works when I have everythi...

How to copy a subset from an array of strings to an array of ints using Groovy?

I have a String array in a Groovy class (args to a main method): String[] args I'd like to convert the 3rd to the last element into a new array of ints. Is there an easier way to do this in Groovy other than: final int numInts = args.length - 2 final int [] intArray = new int[numInts] for (int i = 2; i < args.length; i++) { intA...

Why does my array initialization code cause a StackOverflowException to be thrown?

The following line of code in my class constructor is throwing a StackOverflowException: myList = new string[]{}; // myList is a property of type string[] Why is that happening? And what's the proper way to initialize an empty array? UPDATE: The cause was in the setter, in which I was attempting to trim all values: set { for...

Array of paths to html lists

I wrote a recursive function, which returns an array with the paths to all files/folders in a given path. An array is already sorted and returns the exact information i want, but i struggle to display it properly in html lists. Array_of_paths = ( [0] => /path/to/folderA/ [1] => /path/to/folderA/subfolderAA/ [2] => /path/to/folderB/ [3]...

Assigning each digit of an int to an int array

Is it possible to retrieve an integer using scanf and assigning each digit to a int array? I'm trying to achieve it doing it this way: int numbers[]; puts("Enter number"); int x; scanf("%d",x); numbers = malloc(x); numbers = x; ...

Need help INSERT record(s) MySQL DB

I have an online form which collects member(s) information and stores it into a very long MySQL database. We allow up to 16 members to enroll at a single time and originally structured the DB to allow such. For example: If 1 Member enrolls, his personal information (first name, last name, address, phone, email) are stored on a single r...

Passing array to another class - Objective C

I manage to pass the following array from MessagesTableViewController.m to arraySelectedCategory in another class called MessageDetailViewController.m: self.messageDetailViewController.arraySelectedCategory = [[NSMutableArray alloc] initWithObjects:@"Value 1",@"Value 2", @"Value 3", nil]; but how do I hand over an array stored...

php compare array keys, not values

I am successfully using the array_key_exists(), as described by php.net Example: <?php $search_array = array('first' => 1, 'second' => 4); if (array_key_exists('first', $search_array)) { echo "The 'first' element is in the array"; } ?> But, take out the values, and it doesn't work. <?php $search_array = array('first', 'second'...

Replace string key of PHP array

Hello, I have an array in PHP which looks like that: $test = array('3' => 5); How could I replace the stringed array key 3? I tried: $test['3'] = "New value" but it don't work, it look like that after that: array('3' => 5, 3 => "New value") PHP version: 5.2.11 ...

Basic class returns object reference instead of Array

I have very basic class: class Customer { protected $id; protected $customer; public function __construct($customer_id) { $this->id = $customer_id; return $this->set_customer(); } protected function set_customer() { $query = mysql_query("SELECT * FROM customer WHERE id = '$this->id'"); $this->customer = mysq...