arrays

What are the benefits to using String[] over List<String>?

Possible Duplicates: c# array vs generic list Array versus List<T>: When to use which? I understand that there are several benefits of using List<>. However, I was wondering what benefits might still exist for using arrays. Thanks. ...

How to hard define in code a matrix Integer[][]

Question is simple for an expert Integer[][] res= new Integer[][] {.....hard code some values here on 2 dim...} How to return here 2 rows and 3 cols like this 1 2 3 4 5 6 ...

remove repeated vaules _stack&array

I want to write a program to implement an array-based stack, which accept integer numbers entered by the user.the program will then identify any occurrences of a given value from user and remove the repeated values from the stack,(using Java programming language). I just need your help of writing (removing values method) e.g. input:6 2 ...

Add a method to array object

I've found this post: Array#add_condition But i didn't understand to how implement it in my rails project How can i do it? thanks ...

how to change a while sql query loop into an array loop

hey guys i record number of queries of my website and in page the below script runs , 40 extra queries added to page . how can I change this sql connection into a propper and light one function tree_set($index) { //global $menu; Remove this. $q=mysql_query("select id,name,parent from cats where parent='$inde...

Array in element of object

Why in example 'mytest' isn't an array? class myclass { public $mytest = array(); } $insert = new myclass; $insert -> mytest = Array (15, 50); ...

How to combine two arrays of same length to one array with two fields (not append/merge)

Say, I have an array with months $months = array('Jan', 'Feb', 'Mar'...'Dec'); And another, with days (say, for year 2010) $mdays = array(31, 28, 31...31); I want to merge/combine these two arrays, into an array like this: $monthdetails[0] = ('month' => 'Jan', 'days' => 31) $monthdetails[1] = ('month' => 'Feb', 'days' => 28) ......

How to build array of 'bad' values

I am processing a form and in turn, receiving a response code based on the information submitted. I have a list of approximately 40 response codes (and their meaning) in my hands and am trying to build an 'if' statement that checks against a predefined array and returns a specific value. Just not sure how to do this First pass conceptu...

jQuery: How to check if a value exists in an array?

Hello, I am trying to write a simple input field validation plugin at the moment (more of a learning exercise really) and thought this would not be too hard, seeing as all I should have to do is: Get input fields Store them in array with each one's value On submit of form check if array contains any empty strings But I seem to fail ...

How do Arrays work in C#?

I know that they are used to store data, but I have a difficult time understanding exactly how to use them in a program. In addition, I found this site with a tetris clone tutorial (the actual tutorial is missing). It uses arrays, but I can't really make sense of how it works. Here's an example of the code - public int[, ,] TShape = ...

C++ Array Of Pointers

In C++ if I want an array of pointers so that I may have them point to different objects at a latter stage what does the syntax look like. EDIT I need to clarify what I am trying to do I guess. I have a class foo that has and add method. In the add method I take a reference to class bar. I want to save that reference into a pointer arr...

PHP - My array returns NULL values when placed in a function, but works fine outside of the function

Okay, let me see if I can explain this. I am making a newspaper WordPress theme. The theme pulls posts from categories. The front page shows multiple categories, organized as "newsboxes". Each post should show up only ONCE on the front page, even if said post is in two or more categories. To prevent posts from duplicating on the front ...

php mysql array - insert array info into mysql

I need to insert mutiple data in the field and then to retrieve it as an array. For example I need to insert "99999" into table item_details , field item_number, and the following data into field bidders associated with item_number : userx usery userz Can you please let me know what sql query should I use to insert the info and w...

What is the minimum interface that has the Count property in .Net

Hello, I need to change a method that has one parameter that takes a serie of objects. I need to find the lowest Interface (in inheritance tree) that has the Count property. Until now I was using the IEnumerable but as this has not Count I need to change it to the wider interface possible so the method can work with the biggest number o...

Checking array of censored words against user submitted content

Hello, I have set up an array of censored words and I want to check that a user submitted comment doesn't contain any of these words. What is the most efficient way of doing this? All I've come up with so far is splitting the string into an array of words and checking it against the array of censored words, but I've a feeling there's a n...

PHP scope question

Hi, I'm trying to look through an array of records (staff members), in this loop, I call a function which returns another array of records (appointments for each staff member). foreach($staffmembers as $staffmember) { $staffmember['appointments'] = get_staffmember_appointments_for_day($staffmember); // print_r($sta...

Why is a fixed size buffers (arrays) must be unsafe?

Let's say I want to have a value type of 7 bytes (or 3 or 777). I can define it like that: public struct Buffer71 { public byte b0; public byte b1; public byte b2; public byte b3; public byte b4; public byte b5; public byte b6; } A simpler way to define it is using a fixed buffer public struct Buffer72 { ...

ArrayAccess multidimensional (un)set?

I have a class implementing ArrayAccess and I'm trying to get it to work with a multidimensional array. exists and get work. set and unset are giving me a problem though. class ArrayTest implements ArrayAccess { private $_arr = array( 'test' => array( 'bar' => 1, 'baz' => 2 ) ); publi...

Compare two associative arrays and create a new array with the matched arrays, PHP

I have this two arrays: $arr1=array( array("id" => 8, "name" => "test1"), array("id" => 4, "name" => "test2"), array("id" => 3, "name" => "test3") ); $arr2=array( array("id" => 3), array("id" => 4) ); How can i "extract" arrays from $arr1, where id have same val...

ActionScript Defining a Static Constant Array

is it not possible to define a static const array? i would like to have an optional parameter to a function that is an array of colors, private static const DEFAULT_COLORS:Array = new Array(0x000000, 0xFFFFFF); public function myConstructor(colorsArray:Array = DEFAULT_COLORS) { } i know i can use ...args but i actually wanting to s...