arrays

c++ array class problems

Alright, so without going into detail on why I'm writing this class, here it is. template<class aType> class nArray { public: aType& operator[](int i) { return Array[i]; } nArray() { aType * Array = new aType[0]; _Size = 0; _MaxSize = 0; _Count = 0; } nArray(int Count) { aType * Arra...

How to initialize two-dimensional arrays in Fortran

In C you can easily initialize an array using the curly braces syntax, if I remember correctly: int* a = new int[] { 1, 2, 3, 4 }; How can you do the same in Fortran for two-dimensional arrays when you wish to initialize a matrix with specific test values for mathematical purposes? (Without having to doubly index every element on sepa...

return TCollection or array of objects from Dll

I tried to return from dll function my own object (derived from TCollection). I used FastMemoryManager, but without success... So I tried to return dynamic array of some objects. Length of the array of set of course in dll function. It works realtive good, but allocated memory is not freed. (I measure with Windows tarsk manager). Is th...

How do I get a slice of a referenced array in Perl?

I have a reference to an array $arr_ref. I would like to get a reference to an array containing only cells i..j in the original array. ...

Elegant way to init and extend a javascript array

Is there a sweet way to init an array if not already initilized? Currently the code looks something like: if (!obj) var obj = []; obj.push({}); cool would be something like var obj = (obj || []).push({}), but that does not work :-( ...

Creating a array of multiple form input's ids and values using jquery

Hi guys, I have a bunch of fields that have the same class, now what I am trying to do is get the id and value of each one, create an array, and then using $.ajax send it to a PHP script, which will run through each one and enter it into the database. I tried using JSON, but my server does not have support for json_decode, which is ess...

How do I stop MySQL from duplicating every column's entry in returned arrays?

My MySQL queries are returning arrays with duplicate entries: numbered keys and labeled keys with the same data inside. This may be standard, but it seems like a waste, and something that could cause problems if I'm printing values. I mean, not a huge problem, obviously. But I'm just curious if I can stop that. It seems unnecessary. For ...

How to Use String.Filter with Multi-Value Parameters

In the Expression builder window in SQL Server Reporting Services 2008 R2 under Common Functions -> Text -> Item, there is an expression called Filter. This appears to correspond with the Strings.Filter method in the .NET framework. The description of Filter is as follows: Returns a zero-based array containing a subset of a String arr...

GoogleMaps API v3 polygons from encoded, array problem

I can decode the points, I just need to figure out how to loop through the array of points and produce [ new google.maps.LatLng(39.112456,-84.574779), new google.maps.LatLng(39.314153,-84.261379), new google.maps.LatLng(39.197099,-84.667579), new google.maps.LatLng(39.16836,-84.479381) ]; Code available at http://pastebin.com/Zf6hi4A...

Can't get JavaScript Array to work in OOP style

Hi currently I'm trying to get following snippet of code to work: function Entry() { var pauses = new Array(); } Entry.prototype = { AddElement: function(aParameter) { this.pauses.push(aParameter); } } Unfortunately this code fails with following error in Safari if I try to call AddElement("Test"); TypeError: Result ...

JSON array data retrievability

Hello all, I have another JSON array related question. How would I access the data stored under "when": in this array if I am importing it with JQuery with a statement like this: function getJSON() { $.getJSON('nearby.json', function(data) { console.log(data.when); }); } Here is a snippet from my JSON: ...

JSON array deserialization -- is the order of elements always preserved?

When deserializing a JSON array in C#/.NET, is the order of elements always preserved? Edit: The library currently being used is .NET 3.5's System.Runtime.Serialization.Json.DataContractJsonSerializer ...

PHP shortest/longest string in array

I have an array like this $data = array( "163", "630", "43", "924", "4", "54" ); How can I select the smallest and largest values from it according to string length NOT number value. (for this example it is 1 (smallest) and 3 (largest). ...

C++ Add Object to Array

I need to instansiate an object and add it to an array. This is what I currently have in a method: Row r; rows[count] = r; The problem here is r is on the stack and being removed after the function exits. I quick fix is to make r static but that is bad right? What should I do? (Sorry, complete C++ noob). Edit: Removing the deconstruc...

Ruby core Matrix vs NArray's NMatrix

There seems to be two matrix modules in Ruby that I've found Matrix: Part of core Ruby it seems NMatrix: Part of the NArray library At the moment it seems NMatrix is faster, has some more helpful methods, but require a bit more setup. Is there anyone with experience of both who can give a rough overview of why I should use one over ...

Javascript/JQuery join() method error when using on an array

Hello All, I'm trying to loop through my JSON array and assign a specific key of each element into a variable: Here is the array: "joining_profiles": [ { "pic": "http://graph.facebook.com/832332325303/picture", "id": 3, "name": "Test2 Gmail" }, { "pic": "http://graph.facebook.com/6...

Patterns using loop in java or blueJ

How to print the follwoing pattern in JAVA 1. * * * * * * * * * * * * * * * * 2. * * * * * * * * * * * * 3. * * * * * * * * * * * * * * * 4. B L U E J B L U E B L U B L B 5. B L B U L B E U L B J E U L B ...

Forward declarations for variables?

I have some C code that I have to port to C++. The code has a structure struct A { ... struct A * myPtr; } And now two global arrays are declared and initialized like this: //Forward declaration of Unit struct A Unit[10]; struct A* ptrUnit[2] = { Unit, Unit+7 }; struct A Unit[10] = { { .., &ptrUnit[0] }, ...

Echoing a PHP array is only displaying the first letter of each value

This is a simple rating system. There are 3 values which contain a percentage with an accompanying description/name. I only want to display the the description/name. For some reason, it displays: A T I This is my script: if(isset($_POST['analyze'])) { // get total value of "Time Management" section for($i = 0; $i < 19; $i+...

PHP Simple CSS string parser

I need to parse some CSS code like: color: black; font-family:"Courier New"; background:url('test.png'); color: red; --crap; Into: array ( 'color'=>'red', 'font-family'=>'"Courier New"', 'background'=>'url(\'test.png\')', '--crap'=>'' ) I need to do this via PHP. I can see this done easily via regexp (well, easy to...