arrays

C# Compress Triple Byte Array

Hi. I currently got this script, which compresses byte arrays. But I need it rewritten, so it can compress triple byte arrays [,,] Thanks! public static byte[] Compress(byte[] buffer) { MemoryStream ms = new MemoryStream(); GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true); zip.Write(buffer, 0, buffer.Length); zip.Cl...

Having issues with initializing character array

Ok, this is for homework about hashtables, but this is the simple stuff I thought I was able to do from earlier classes, and I'm tearing my hair out. The professor is not being responsive enough, so I thought I'd try here. We have a hashtable of stock objects.The stock objects are created like so: stock("IBM", "International Business M...

C# struct with an array

I am making a game using C# with the XNA framework. The player is a 2D soldier on screen and the user is able to fire bullets. The bullets are stored in an array. I have looked into using Lists and arrays for this and I came to the conclusion that an array is a lot better for me, as there will be a lot of bullets firing and being destroy...

Finding unique elements in an string array in C

Hi, C bothers me with its handling of strings. I have a pseudocode like this in my mind: char *data[20]; char *tmp; int i,j; for(i=0;i<20;i++) { tmp = data[i]; for(j=1;j<20;j++) { if(strcmp(tmp,data[j])) //then except the uniqueness, store them in elsewhere } } But when i coded this the results were bad.(I han...

Writing a blackjack console program in Java

Hello, I have an assignment of making a blackjack like program in a class. My first problem I am dealing with is creating an array of the cards. The professor wants an array setup with a txt file with the following format. 2 of hearts 2 of diamonds 2 of spades 2 of clubs 3 of hearts 3 of diamonds 3 of spades This goes on till face ca...

Java queue and multi-dimension array

First of all, this is my code (just started learning java): Queue<String> qe = new LinkedList<String>(); qe.add("b"); qe.add("a"); qe.add("c"); qe.add("d"); qe.add("e"); My question: Is it possible to add element to the queue with two values, like: qe.add("a","1"); // where 1 is integer So, that I know element "a" have value 1. ...

How to sort a multidimensional array by a certain key?

This should be really simple, but what is the way to go on this. I want to sort an multidimensional array by a key, like this: Array ( [0] => Array ( [iid] => 1 [invitee] => 174 [nid] => 324343 [showtime] => 2010-05-09 15:15:00 [location] => 13 [status] => 1 [created] => 2010-...

Why aren't arrays expandable?

When we create an array, we cannot change its size; it's fixed. OK, seems nice, we can create a new bigger array and copy the values one by one and that's little slow. What's the technical background of it? ...

How to pass object array as parameter in java

The method is public static void method(Object[] params), how should I call it in the following scenarios? with one object as parameter ClassA a with more than one objects as parameters ClassA a, ClassB b, ClassC c? thank you ...

Array of Structs Initialization....

Hi I am working on a program where I have to initialize a deck of cards. I am using a struct to represent a card. However I'm not filling it correctly as I get a bunch of zero's when I display the deck of cards. I believe my mistake is in this line but I'm not sure: struct card temp = {"Clubs", value, false}; The code: void initCard...

Put an array of Objects in nodes of another array of Objects [JAVA]

public class hello { public static void main(String[] args) { Object[] newarray = new Object[1]; Object[] obj = new Object[2]; obj[0] = "Number1"; //string value obj[1] = "Number2"; //string value newarray[0] = obj; //this works Object[] tmp_obj = new Object[2]; tmp_obj ...

Given an array of arrays, how can I strip out the substring "GB" from each value?

Each item in my array is an array of about 5 values.. Some of them are numerical ending in "GB".. I need the same array but with "GB" stripped out so that just the number remains. So I need to iterate through my whole array, on each subarray take each value and strip the string "GB" from it and create a new array from the output. Can a...

PHP 'Years' array

I am trying to create an array for years which i will use in the DOB year piece of a form I am building. Currently, I know there are two ways to handle the issue but I don't really care for either: 1) Range: I know I can create a year array using the following <?php $year = range(1910,date("Y")); $_SESSION['years_arr'] = $y...

How do I prevent a char pointer buffer overflow?

i.e. - int function(char* txt) { sprintf(txt, "select * from %s;", table); //How do I set last char in buffer to NULL here? } so if the text in table some how was 500 chars long and txt in the main was only defined as 100.... thanks. ...

NSString to NSURL objects

Hello, I have an array that I populated with my plist file, which looks something like this: <array> <string>http://www.apple.com&lt;/string&gt; <string>http://www.google.com&lt;/string&gt; <string>http://www.amazon.com&lt;/string&gt; </array> So, I'm looking to convert these NSString objects to NSURL objects when I call them...

Randomly generate sound from onClick and onShake events?

I've literally looked everywhere on the net and found very little clarification on how to do this. Pretty much, I have 8 sound files laid out in an array.xml file and I need to play a randomly chosen file ONCE per or onClick or onShake. First off, what technique should I use to achieve this? ARRAY->RANDOM- STRING->PLAY? RANDOM...

JavaScript Multidimensional Arrays

This wasn't the question I was going to ask but I have unexpectedly run aground with JavaScript arrays. I come from a PHP background and after looking at a few websites I am none the wiser. I am trying to create a multi-dimensional array. var photos = new Array; var a = 0; $("#photos img").each(function(i) { photos[a]["url"] = this...

Need help iteratating over an array, retrieve two possibilites, no repeats, for Poker AI

I can't really think of a good way to word this question, nor a good title, and maybe the answer is so ridiculously simple that I am missing it. I am working on a poker AI, and I want to calculate the number of hands that exist which are better than mine. I understand how to that, but what I can't figure out is the best way to iterate ...

is there any short method to obtain value of array in php

When I obtain a field 'text' of an array I have to do something like this: $text = isset($tab['text'][0])?$tab['text'][0]:""; is there any function that returns value when element $tab['text'] exists and "" when not and of course doesn't produce notice in latter case. ...

Reference to array not working as expected in PHP

hi guys, I am confused from the result of the following code: I can't get my expected result: $arrX = array('a'=>array('val'=>10),'b'=>array('val'=>20), 'c'=>array('val'=>30)); foreach( $arrX as &$DataRow ) { $DataRow['val'] = $DataRow['val'] + 20; } foreach( $arrX as $DataRow ) { echo '<br />val: '.$DataRow['val'].'<br/>'; } ...