Multidimensional Array in TableView

I'm working on a program that stores some variables in a multidimensional array (NSMutableArrays in a NSMutableArray). My array looks something like this:
hopSoort
hopDosering
alfaZuur
kookTijd
Saaz (CZ)
16
3.2
60
EK Goldings
20
5.6
60
I've made a class with two methods (for adding rows, and for doing the math). I'm just testing the logic in a command line application and all seems to work fine. But eventually I want to make a Cocoa app and use the TableView to add/edit/delete rows.
Is this the correct way to go? If desired I can post some code.

I fixed it by using a NSMutableArray with a NSMutableDictionary objects as childs. Now I need to convert my other classes to use NSMutableDictionaries instead of NSMutableArrays.

Similar Messages

  • How to pass a multidimensional array to an Oracle procedure?

    How can I pass a multidimensional array to oracle array?
    Thanx in anticipation,

    Look in to passing user defined type back and forth to Oracle. Any type that oracle supports, you can constract on the java side and send it across. Look into the SQLData class.

  • Bindind data to multidimensional Array

    I have a multidimensional Array (3D). I have some fields which I want to bind to some TextInputs:
    model.creditosConsumoModel.literaturaCredito[i][j][k]
    And here's a example of the data binding:
    text="{(model.creditosConsumoModel.literaturaCredito[4][12][0] as Apartado).texto}"
    The problem is: When I do a: model.creditosConsumoModel.literaturaCredito = new Array and I define the Array again with new data everything gets blank (all the text Inputs) and I loss the information.
    Resume: It only works the first time, but not the rest of the times.
    Thanks and regards!!!

    @Pauland
    That's what I was thinking as it was an array of arrays.
    @quebequiano
    Generally, for something like this, I make a wrapper object and set the values on that so I don't have to deal with issues like this.  I'm not sure how architecturally sound it is, but it sounds like you are trying to take small pieces of data and prepare them for your view, in which case a wrapper/adapter would provide you with the benefits of databinding.
    P.S Does your name mean "Quebecian" in spanish ?

  • Problems making windchill chart using multidimensional arrays

    Alright i am doing a program for my java class. The book doesnt tell me much and the teacher didnt either cause we had a midterm to take. Alright in this program i have to write a java program that produces a wind chill chart with temperatures from 50 to -50 degrees f in steps of 10 degrees, with wind speeds from 5 to 50mph, in steps of 5mph. The following formula may be useful.
    windchill= ((10.45+6.686112 * sqrt(windspeed)- .447041 * windspeed)/22.034)*(temperature- 91.4) + 91.4
    use for statements in your program and a function to calculate the wind chill factor at a given temperature and wind speed.
    I know im gonna have to use multidimensional arrays to do this problem, unless someone has an easier way to do it. I am really stuck. I have this so far.
    import javax.swing.*;
    public class lab7
    public static void main( String args[] )
    int a[][] = {{5,10,15,20,25,30,35,40,45,50},
    {-50,-40,-30,-20,-10,0,10,20,30,40,50}};
    System.exit(0);
    I am not even sure if that is correct but the major problem is how can i get the program to show a table with the temperature on the x coordinate at the top the wind speed on the y axis and then having the program use those arrays to calculate the windchill and put that in the table. I am really stuck and i was wondering if u guys could give me a little push in the right direction. The book doesnt say much so thats why im asking.
    Thank you everyone.

    I have no clue what i am doing right now. I am so confused it isnt even funny. I am trying something new to see what happens. The decimalformat didnt do anything for me. I have the numbers i just want to be able to put them into a chart. I wish my teacher would actually teach, and the book actually say how to do stuff.
    This is my program:
    import java.text.DecimalFormat;
    public class lab7
    DecimalFormat twoDigits = new DecimalFormat ("0.00");
    static private double windchill(double s, double t) { 
    return (((10.45 + 6.686112 * Math.sqrt(s) - .447041 * s)/(22.034))*(t-91.4) + 91.4);};
    static void print(double s, double t)
    {   System.out.print(" "+windchill(s, t));};
    static private void printRow(double s)
    { // the speed is assumed constant  
    for (double t= -50; t <= 50; t+= 10) // loop over the temperature values
    print(s, t); // print a row value
    System.out.println();};
    static private void printChart()
    {   for (double s= 5; s <= 50; s+= 5)      
    printRow(s);};
    public static void main(String args[])
    for (double t= -50; t <= 50; t+= 10) // loop over the temperature values
    {System.out.print( "   " + t);};
    System.out.println();
    System.out.println();
    for (double s= 5; s<=50; s+= 5)
    {System.out.println(s);};
    printChart();
    I am probably way off and this program is due tomorrow and i am going nuts. I tried to do it during the week and it didnt work out to well.
    Here is what it is outputting.
    C:\cis260>java lab7
    -50.0 -40.0 -30.0 -20.0 -10.0 0.0 10.0 20.0 30.0 40.0 50.
    0
    5.0
    10.0
    15.0
    20.0
    25.0
    30.0
    35.0
    40.0
    45.0
    50.0
    -57.26056937082865 -46.747092046159025 -36.233614721489374 -25.720137396819737
    -15.2066600721501 -4.6931827474804635 5.820294577189159 16.333771901858796 26.84
    7249226528433 37.36072655119807 47.87420387586771
    -82.65748711959239 -70.3479052865236 -58.03832345345484 -45.728741620386074 -33
    .41915978731731 -21.109577954248536 -8.799996121179774 3.5095857118890024 15.819
    167544957764 28.128749378026534 40.4383312110953
    -98.80774164293763 -85.35599188035366 -71.90424211776966 -58.452492355185655 -4
    5.00074259260168 -31.54899283001768 -18.097243067433695 -4.645493304849694 8.806
    256457734293 22.25800622031828 35.70975598290227
    -110.17157107350803 -95.91615586321751 -81.66074065292699 -67.40532544263644 -5
    3.14991023234592 -38.894495022055395 -24.639079811764873 -10.38366460147435 3.87
    17506088161713 18.127165819106693 32.38258102939722
    -118.4766111010257 -103.63385218298993 -88.79109326495416 -73.94833434691841 -5
    9.105575428882645 -44.262816510846875 -29.42005759281112 -14.57729867477535 0.26
    54602432604065 15.108219161296176 29.95097807933194
    -124.60889848734033 -109.33245587861754 -94.05601326989475 -78.77957066117196 -
    63.50312805244914 -48.22668544372635 -32.950242835003564 -17.67380022628076 -2.3
    973576175579723 12.87908499116483 28.15552759988762
    -129.09477971074705 -113.50108949075079 -97.90739927075452 -82.31370905075829 -
    66.72001883076203 -51.12632861076577 -35.53263839076952 -19.93894817077326 -4.34
    5257950777011 11.24843226921925 26.842122489215498
    -132.2771986196876 -116.45844341320333 -100.63968820671906 -84.82093300023479 -
    69.00217779375052 -53.18342258726625 -37.36466738078198 -21.545912174297698 -5.7
    27156967813428 10.09159823867084 25.91035344515511
    -134.39436482483956 -118.42588074953267 -102.45739667422575 -86.48891259891886
    -70.52042852361197 -54.55194444830505 -38.58346037299816 -22.614976297691257 -6.
    646492222384367 9.321991852922537 25.29047592822944
    -135.61971729379445 -119.56457462803812 -103.50943196228181 -87.45428929652547
    -71.39914663076914 -55.34400396501283 -39.288861299256496 -23.233718633500175 -7
    .178575967743839 8.876566698012482 24.931709363768803
    C:\cis260>
    All i want it to do is look like this: im just gonna make numbers in between just say that there is numbers in that whole thing. What am i missing. Thanks everyone so far for everything, i just need a little more and it should be done.
    -50 -40 -30 -20 -10 0 10 20 30 40 50
    5 65 44 55 78 4 45 etc etc etc
    10
    15
    20
    25
    30
    35
    40
    45
    50

  • Multidimensional Array in Indesign?

    Hey guys,
    normally in javascript I can just create a multidimensional array like so:
    myArray = [ [] ];
    and then assign values like this:
    myArray[0][0] = 'item1';
    In extendscript I get the error "undefined is not an object". Is there something I forgot about, or is this just not possible in Indesign?

    I found out it was another problem. The code works like this, but you need to define in the beginning how many arrays are in the array. Otherwise it will throw the "undefined" error.
    points = new Array(object.paths.length);
    for(i = 0 ; i<object.paths.length; i++){
        points[i] = new Array();
    This code works now, as the length of the array is exactly the length you need. And for every key you add another array, to create your two dimensional array on every key.

  • MultiDimensional Array or what????

    Hi Guys
    I have created an xml document that has this structure for
    each child:
    <work>
    <client>Telstar Records</client>
    <titled>Stargate Music.co.uk</titled>
    <thumb>images/thumbs/stargate_sm.jpg</thumb>
    <description>They were an up and coming band, i was a
    designer with a passion for 3d, they met fell in love and a new
    site was born. All it took was four press shots, one promo and a
    lot of imagination</description>
    <images>
    <image>images/large/telstar_sg_01.jpg</image>
    <image>images/large/telstar_sg_02.jpg</image>
    <image>images/large/telstar_sg_03.jpg</image>
    </images>
    <link>
    http://www.4zero1.co.uk/backupsites/stargate/index.html</link>
    </work>
    I have succesfully created buttons and used an associative
    array to compile the info for each button, woooooo aren't i
    clever!!!! I have set up a path to the <images> node, but I
    am stumped as to how i can pull the information from the
    'workImages' variable in my getworkData() function below .
    I need your help, as i would like to create buttons of the
    childnodes named <image> in the xml, above you can see that
    if i was successful i would have three buttons. My problem is
    relating the information to the buttons and making the buttons
    appear. I am not using a for loop as i would like to animate each
    button using a scripted tween. as in the makeButtons() function.
    Do I need to create a multidimensional array? I have included
    my code below, please don't get too lost in it, i hope someone can
    fathom it for me and give me an answer. My associative array is in
    the function getworkData(); My function to create the 'image'
    buttons is called portfolioImageCreator();
    Many thanks
    Jim

    You could use a table of records or a record group. They both achieve similar results but with very different syntax. I am not sure if there is any difference in performance.
    Record groups are good for certain things like lists populated from the database because built-ins are provided for manipulating them. If you are going to do the manipulation programatically, I personally find the syntax for tables of records less cumbersome than record groups. Learning the syntax for tables of records is also likely to be more universally useful to you as they have various uses such as passing data between procedures.
    In your situation the table of records needs to exist throughout the forms session rather than just during the execution of a single pl/sql block. The way to do that is create a program unit which is a package header without a body. Declare the table in there and it can be used throughout the form.
    However, if you only ever want to keep 5 records, it would probably be easier just to have 5 ordinary items in a control block on the null canvas (or global variables). When you want to record your new action just do:
    :item5 := :item4;
    :item4 := :item3;
    :item3 := :item2;
    :item2 := :item1;
    :item1 := :new_stuff;
    You could even construct the above in a loop using
    copy(name_in('item'||i),'item'i+i)
    but with only 5 items to manipulate, is it worth the bother ?
    Whatever method you decide to use, you are not going to get anything simpler than 5 little assignment statements.

  • Multidimensional array and chars

    Hi again,
    My apologies in advance if i can't word my question that well, i will try and be as clear and succinct as possible and hopefully for this newbie you can apprehend what i'm trying to figure out if i come up short.
    I'm trying to write a rather large control statement with a while loop and several nested ifs inside it that ultimately returns a single character after all is said and done, and then continually concatenates that character to a string which will eventually be output to a file. The part i'm stuck at is after i've changed the two letter characters into their ASCII values. I need to make the program take those two ASCII values and use them as a reference to a character in a multidimensional array of alphabetic characters, and then that character will be what is returned at the end.
    Here's the method, thanks in advance for your time.
    public String encode( String cipherKey )
            String textToEncode = input.next();
            String encodedText = " ";
            cipherKey = cipherKey.toUpperCase();
            textToEncode = textToEncode.toUpperCase();
            openFiles();
            int numberOfChars = textToEncode.length();
            int cipherPos = 0;
            int cipherLength = cipherKey.length();
            while (input.hasNext())
                for ( int count = 0; count < numberOfChars; count++ )
                    if (Character.isLetter(textToEncode.charAt(count)))
                        cipherPos %= cipherLength;
                        int xChar = (int) textToEncode.charAt(cipherPos);
                        int yChar = (int) textToEncode.charAt(count);
                        xChar -= 65;
                        yChar -= 65;
                        if ((xChar >= 0) && (xChar <= 25))
                            if ((yChar >= 0) && (yChar <= 25))
                        return ' ';
                     encodedText = encodedText +
        return encodedText; 
        }As you can see towards the end there are some incomplete statements where i became lost.

    its there, i couldnt c&p the whole program because it went over my character limit. Yeah it did compile but couldn't invoke my encode method without a NullPointerException.
    Here are the other methods in the class....
        public String setSource( String in )
            source = in;
            return source;
         Sets the value of the output file
         * @param out A <code>String</code> value representng name of output file.
         * @see #setSource
        public String setDestination( String out )
            destination = out;
            return destination;
         * Method to open both input and output files, and to test for exceptions
         * @see #encode
         * @see #decode
        private void openFiles()
        File inputFile = new File(source);  //Creates new file object from source file
        File outputFile = new File(destination);  //Creates new file object from destination file
            /* Tests whether input file exists and if so enables the Scanner
             * to read the data in from the source file. Catches SecurityException and
             * FileNotFoundException amd prints appropriate messages to user.
            if (inputFile.exists())
                try
                    input = new Scanner( new File( source ) );
                    FileReader reader = new FileReader(inputFile);
                    BufferedReader BufferIn = new BufferedReader(reader);
                catch ( SecurityException securityException )
                    System.err.println("You do not have read access to this file.");
                    System.exit( 1 );
                catch ( FileNotFoundException filesNotFoundException )
                    System.err.println("Error: File does not exist.");
                    System.exit( 1 );         
            /* Tests whether output file exists and if it does enables Formatter
             * to write encoded output to file. Catches SecurityException and
             * FileNotFoundException and prints appropriate message to user.
            if (outputFile.exists())
                try
                    output = new Formatter( new File( destination ) );
                catch ( SecurityException securityException )
                    System.err.println("You do not have write access to this file.");
                    System.exit( 1 );
                catch ( FileNotFoundException filesNotFoundException )
                    System.err.println("Error: File does not exist.");
                    System.exit( 1 );
         * Closes both input and output files after output file has been written
         * to.
         * @see #openFiles
        private void closeFiles()
            if ( output != null )
                input.close();
                output.close();
        }Edited by: fearofsoftware on Apr 17, 2009 8:35 PM

  • Multidimensional array in jquery class/object

    I'm trying to get into javascript and jquery for a hobby project of mine. Now I've used the last 4 hours trying to find a guide on how to create class objects that can contain the following information
    Identification : id
    Group : group
    Persons : array(firstname : name, lastname : name)
    Anyone know of a tutorial that can show me how to do this?
    I found this page where I can see that an object can contain an array, but it doesn't state whether it is possible to use a multidimensional array.
    And this page just describes the object with normal values.
    Any pointers in the right direction are appreciated.

    There are no classes in JavaScript. It uses a different style of objects and what you found is indeed what you need.
    Well, it might help to think about it as a dynamic, runtime-modifiable object system. An Object is not described by class, but by instructions for its creation.
    Here you have your object. Note that you can use variables everywhere.
    var id = 123;
    var test = {"Identification": id,
    "Group": "users",
    "Persons": [{"firstname":"john", "lastname":"doe"},{"firstname":"jane","lastname":"doe"}]
    This is identical to the following code. (The first one is a lot nicer, though.)
    var id = 123;
    var test = new Object();
    test.Identification = id;
    test["Group"] = "users;
    test.Persons = new Array();
    test.Persons.push({"lastname":"doe","lastname":"john"});
    test.Persons.push({"lastname":"doe","lastname":"jane"});
    As you can see, you can dynamically add new properties to an object. You can use both the dot-syntax (object.property) and the hash syntax (object["property"]) in JavaScript.

  • JNI multidimensional Array and OpenCV

    Hello everybody,
    my first post, so lets go..
    At the moment I am writing my thesis in the filed of automatic image classification. The project is written in Java, but I wanna use the OpenCV library from Intel (http://sourceforge.net/projects/opencvlibrary/) for facedetection.
    So far I managed to call the native method from Java. What I do I parse the path of the image to be analyzed as a string to my C++ programm. The faces are being detected and written into a so called CvSeq (http://www.comp.leeds.ac.uk/vision/opencv/opencvref_cxcore.htm#cxcore_ds_sequences) which holds the coordinates of the rectangles surrounding the found faces. Until now I can only call cvSeq->total which gives me the total number of faces as ints. That integer I return to my java api.
    What I don't know is, how to return a multidimensional array (2 dimensions) where the first dim contains the path as a string to the file and the second dimension 3 integers for x,y coordinates and the lenght of each rectangle.
    Or better, I might know how to return that Array, but not how to create it.
    I know this is somewht OpenCV specific, but maybe someone knows anything. Any little help would be greatly appreciated. Thanks a lot!!!!
    Regards
    Carsten
    attached: JNI source code
    /////////////////////////////////////////// source code ///////////////////////////////////////////////
    #include "cv.h"
    #include "highgui.h"
    #include "cxcore.h"
    #include "cxtypes.h"
    #include "cvaux.h"
    #include "org_kimm_media_image_data_JNIOpenCV.h"
    #include <stdio.h>
    JNIEXPORT jint JNICALL
    Java_org_kimm_media_image_data_JNIOpenCV_getFaces(JNIEnv *env, jobject object, jstring path)
    //declarations
    CvHaarClassifierCascade *pCascade = 0;
    CvMemStorage *pStorage = 0;
    CvSeq *pFaceRectSeq;
    int scale=1;
    jobjectArray recPoints;
    const char *str = env->GetStringUTFChars(path, 0);
    //initializations
    IplImage* pInpImg = cvLoadImage(str, CV_LOAD_IMAGE_COLOR);
    IplImage* small_image = pInpImg;
    pStorage = cvCreateMemStorage(0);
    pCascade = (CvHaarClassifierCascade *)cvLoad
         (("C:/OpenCV/data/haarcascades/haarcascade_frontalface_default.xml"),0, 0, 0 );
    //validaste that everything initilized properly
    if( !pInpImg || !pStorage || !pCascade)
         printf("Initialization failed: %s \n",
              (!pInpImg) ? "didn't load image file" :
              (!pCascade) ? "didn't load Haar Cascade --"
                   "make sure Path is correct" :
              "failed to allocate memory for data storage");
         exit(-1);
    //performance boost through reducing image size by factor 2          
              small_image = cvCreateImage( cvSize(pInpImg->width/2,pInpImg->height/2), IPL_DEPTH_8U, 3 );
    cvPyrDown( pInpImg, small_image, CV_GAUSSIAN_5x5 );
    scale = 2;
    //detect faces in image
    pFaceRectSeq = cvHaarDetectObjects(small_image, pCascade, pStorage,
                                            1.1,                                        //increase search scale by 10% each pass
                                            6,                                        //drop group of fewer than three detections
                                            CV_HAAR_DO_CANNY_PRUNING,          //skip regions unlikely to contain faces
                                                 cvSize(50,50));                         //use XML default for smallest search scale
    //initialize array for location of the faces (HERE IS WHERE I GET INTO TROUBLE!!!!!)
    int x = pFaceRectSeq->total;
    jclass intArrCls = env->FindClass ( "[I" ) ;
    recPoints = env->NewObjectArray ( x, intArrCls, NULL ) ;
    //for(int j = 0; j <= x; j++) {
    //   recPoints[j] = (jintArray)env->NewIntArray(3);
    for(int i=0;i<(pFaceRectSeq ? pFaceRectSeq->total:0); i++)
                                       CvRect* r = (CvRect*)cvGetSeqElem(pFaceRectSeq, i);
                                       CvPoint pt1 = {(r->x)*scale, (r->y)*scale};
                                       CvPoint pt2 = {(r->x + r->width)*scale, (r->y + r->height)*scale};
    //env->SetObjectArrayElement(recPoints,i, pt1.x);
    return pFaceRectSeq->total;
    }

    Any Java array you can consider like one-dimensional array of arrays n-1 dimension. For example, you have a 3 dim. array of objects:
    Object[][][] arr = new Object[1][2][6]; It can be considered as a set of one-dimensional arrays:
    ==========================================
    |  dim   |           Type
    ==========================================
      0          1 element, an array of type �[[Ljava/lang/Object;�
      1          1 x 2 elements , an arrays of type �[Ljava/lang/Object;�
    So you can convert three-dimensional array to one-dimensional array like in C++:
    |�[Ljava/lang/Object;� | �[Ljava/lang/Object;� | �[Ljava/lang/Object;�
         6 objects                 6 objects                 6 objects

  • Question on System.arraycopy method and multidimensional array

    I'm trying to copy from single dimensional to multidimensional array using System.arraycopy method. The following is my problem.
    1) I need to specify the index of the multidimensional array while copying. Can I do that ? If yes , how???
    eg ; int a[] = new int[3];
    int b[] = new int[3][2]; I need to copy from a to b
    I tired the following and I'm getting an error.
    System.arraycopy(a,0,b[][1],0,3);
    How Can I achieve the above?? PLease Help --------------

    Java doesn't have multidimensional arrays. When you see an int[][] it's an array of arrays of ints. The arrays of ints might have different lengths like this one:int[][] arr =
    {{1,2,3,4},
    {1,2,3},
    {1,2},
    {1}
    };Do I need to say that arraycopy as you see it would fail in this case?
    If you know what kind of arrays you'll have you can simply implement your own arraycopy method (but it will not be as effecient as System.arraycopy) with a simple for-loop.

  • Synthesis bug with SV packed multidimensional array slices

    I've been using SV packed multidimensional arrays to do things like representing a bus which is many bytes wide, e.g. a 128-bit bus can be declared like this:
    logic [15:0] [7:0] myBus;
    You should be able to write "myBus[15:8]" to get the upper 64 bits (8 bytes) of this 128-bit wide packed value. However, I've found that in some expressions this produces some very buggy behavior. I've reduced it to a simplified example, with comments to show what works and what doesn't.
    `timescale 1ns / 1ps
    module sv_array_select (
    input logic sel,
    input logic [3:0] [1:0] i,
    output logic [3:0] outA,
    output logic [3:0] outB,
    output logic [3:0] outC
    // Works; equivalent to assign outA = {i[1], i[0]};
    assign outA = i[1:0];
    // Works; equivalent to assign outB = {i[3], i[2]};
    assign outB = i[3:2];
    // FAILURE
    // Synthesizes to equivalent of:
    // assign outC[2:1] = sel ? i[2] : i[0];
    // assign outC[3] = 1'bZ;
    // assign outC[0] = 1'bZ;
    assign outC = sel ? i[3:2] : i[1:0];
    endmodule
     I get this result in Vivado 2015.2 and 2013.2, haven't tried other tool versions.

    ,
    Yes, I can see that incorrect logic is getting generated by the tool.
    I will file a CR on this issue and will let you know the CR number.
    Thanks,
    Anusheel
    Search for documents/answer records related to your device and tool before posting query on forums.
    Search related forums and make sure your query is not repeated.
    Please mark the post as an answer "Accept as solution" in case it helps to resolve your query.
    Helpful answer -> Give Kudos
     

  • Multidimensional Array Sort

    Please help. I am very new to java and trying to build a multidimensional array. I have two variables 1)item_name and 2)item_value. These are values that I obtain by looping through a database result set. I need to build and array that can hold these variables. Once the multidimensional array is built I need to be able to sort it by item value.
    For example I would like to do something like this:
    while (rs.next)
    array.name = item_name
    array.value = item_value
    end
    array.sort(value)
    Thanks for any help!

    Don't use a multidimensional array. Use an array of objects, where the objects are of a class that you define. It might be something as simple as class Item that just has two fields--name and value--and their getters and setters. Or maybe just getters if you want the class to be immutable.
    Have the class implement Comparable and sort on value.
    If you sometimes want to sort on value and sometimes on name, then you'll need to either define two Comparators (one for name, one for value) or make the class Comparable on whichever is the more "natural" ordering and define a Comparator for the other one.
    Either put them in an array and use one of the java.util.Arrays.sort methods to sort them, or put them in a List (java.util.LinkedList or java.util.ArrayList) and use Collections.sort to sort them.

  • Reading Java multidimensional array in C

    Hello friends.
    Have searched the forum, but haven's found the answer.
    I need to access a Java two dimensional array from C ( boolean[][] a; ).
    Here's the code in C:
      jbooleanArray aArray; 
      jboolean **a;   
      fid=(*env)->GetFieldID(env, cls, "a", "[[Z"); 
      if (fid==0) { return; }  aArray=(*env)->GetObjectField(env, jobj, fid); 
      len=(*env)->GetArrayLength(env, aArray); 
      a=(jboolean **) (*env)->GetBooleanArrayElements(env, aArray, 0);Array lengths are correctly read separately. When I debug array in C it fails half-way or so:
      for (i=0;i<arows;i++)   
        for (j=0;j<acols;j++)      
          printf("a[%d][%d]=%u ",i,j,a<i>[j]);Error: An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x189217B4
    Is it the correct way to read multidimensional array? Or could it be the problem with jboolean type?
    Kev

    Thank you for the idea to test an multidimensional array.
    I testet the following code with C++ and changed it afterwords (untestet) into the syntax of C. Hope it runs.
    boolean[][] is an array of Objects, this Objects are arrays of boolean!
    #include "nativetest_BooleanArrayTest.h"
    #include <stdio.h>
    // without "if(blabla == 0) return;" etc.
    JNIEXPORT void JNICALL Java_nativetest_BooleanArrayTest_test
      (JNIEnv * env, jobject obj)
       jsize i, j;
       jclass clazz = (*env)->GetObjectClass(env, obj);
       jfieldID fid = (*env)->GetFieldID(env, clazz, "b", "[[Z");
       jobject jobj = (*env)->GetObjectField(env, obj, fid);
       jobjectArray jarrRows = (jobjectArray)jobj;
       // Get elements of array
       jsize numberOfRows = (*env)->GetArrayLength(env, jarrRows);
       jboolean** carr = new jboolean*[numberOfRows];
       jbooleanArray* jrows = new jbooleanArray[numberOfRows];
       for (i = 0; i < numberOfRows; ++i) {
          jrows[i] = (*env)->GetObjectArrayElement(env, jarrRows, i);
          carr[i]  = (*env)->GetBooleanArrayElements(env, jrows, 0);
    jsize numberOfColumns = (*env)->GetArrayLength(env, jrows[0]);
    // test
    for (i = 0; i < numberOfRows; ++i) {
    for (j = 0; j < numberOfColumns; ++j) {
    // printf ...
    // release
    for (i = 0; i < numberOfRows; ++i) {
    (*env)->ReleaseBooleanArrayElements(env, jrows[i], carr[i], 0);
    delete[] jrows;
    delete[] carr;

  • Memory Consumption in Multidimensional Arrays

    Hi,
    I've noticed that the memory consumption of multidimensional arrays in Java is sometimes far above one could expect for the amount of data that is being stored. For example, here is a simple program which stores a table containing only integers and reports the memory consumption after it is filled:
    public static void main(String[] args) {     
    int tableSize = 1000000;
    int noFields = 10;
    Random rnd3 = new Random();          
    int arr[][] = new int[tableSize][noFields];
    for (int i = 0; i < tableSize; i++) {
    for (int j = 0; j < noFields; j++) {
         arr[i][j] = rnd3.nextInt(100);
    Runtime.getRuntime().gc();
    Runtime.getRuntime().gc();
    Runtime.getRuntime().gc();                    
    // Ensures table's data is still referenced
    System.out.println(arr[rnd3.nextInt(arr.length)]);
    long totalMemory = Runtime.getRuntime().totalMemory();
    long usedMemory = totalMemory-Runtime.getRuntime().freeMemory();
    System.out.println("Total Memory: " + totalMemory/(1024.0*1024) + " MB.");
    System.out.println("Used Memory: " + usedMemory/(1024.0*1024) + " MB.");          
    Output:
    Total Memory: 866.1875 MB.
    Used Memory: 62.124053955078125 MB.
    In this case the memory consumption was around 20MB above the expected 38MB required for storing 10M integers. The interesting thing is that the memory consumption varies when the numbers of rows and columns are changed, even though the total amount of items is kept fixed (see below):
    Rows:100; Cols:100000 -> Used Memory: 43,05 MB
    Rows:1000; Cols:10000 -> Used Memory: 43,07 MB
    Rows:10000; Cols:1000 -> Used Memory: 43,24 MB
    Rows:100000; Cols:100 -> Used Memory: 44,96 MB
    Rows:1000000; Cols:10 -> Used Memory: 62,15 MB
    Rows:10000000; Cols:1 -> Used Memory: 192,15 MB
    Any ideas about the reasons for that behavior?
    Thanks,
    Marcelo

    mrnm wrote:
    In this case the memory consumption was around 20MB above the expected 38MB required for storing 10M integers.That's only the expected value if you assume that a 2D array of ints is nothing more than a bunch of ints lined up end to end. This is not the case. A "2D" array in java is really just a plain ol' array whose component type is "reference to array".
    The interesting thing is that the memory consumption varies when the numbers of rows and columns are changed, even though the total amount of items is kept fixed (see below):That's because, e.g., new int[200][100] creates 200 array objects (and references to each of them), each of which holds 100 ints, while new int[100][200] creates 100 array objects (and references to each of them), each of which holds 200 ints.
    Edited by: jverd on Feb 24, 2010 11:17 AM

  • How to save joint's coordinates into multidimensional array

    Hello everyone, 
    i have a question that's seems silly but i'm stuck in it since yesterday !
    i'm developping a small application with ms kinect sdk 1.7 and when detecting skeleton and all joints are tracked i want to save it into multidimensional array of (20,3) which are respectively the number of joints in human body and the coordinates along
    the 3 axes. 
    my goal is to calculate after that the max and the min values throught the 3 axes.. so i began with this piece of code.
    private static double[][] JointTab = new double [20][3];
    double save_joints(Skeleton first)
    foreach (Joint j in first.Joints)
    for (int li = 0; li < 20; li++)
    JointTab[li][0] = j.Position.X;
    JointTab[li][1] = j.Position.Y;
    JointTab[li][2] = j.Position.Z;
    return JointTab;
    it indicates that the method does not return a value necessary ? how could i fix this error ? 
    i will need to call the JointTab after that how can i sort each colomn with Array.Sort() method  ?
    thanks for any help ! 
    DKF

    The issue you are having is not specific to the Kinect SDK. You will need to look into your managed code construction of the array since that is not valid. There are ways to create a single array of a structure which you can then provide your own enumeration.
    You may want to look at the generic collections of .Net to see what would be best since you will way to provide some logic to the sort since the points in space will need to calculate a length.
    Carmine Sirignano - MSFT

Maybe you are looking for

  • Multiple Rows Into One Column Field

    Hi All,        Today I tried one query: select wm_concat(ename) from emp group by deptno; I have a data that looks like this. CLARK,KING,MILLER,SREE JONES,FORD,ADAMS,SCOTT ALLEN,MARTIN,BLAKE,TURNER,JAMES,WARD Can someone help me to build an SQL comma

  • Error Message relating to cache ???

    I am getting a weird error message which says: "The following errors occurred while trying to open this document: Missing File cache-1 Missing File cache Missing File cache-2" This page has 4 images which I retrieved from iPhoto, and appear on the iW

  • Vendor Customer Clearing

    Hi, We have Customer in one Co. Code and Vendor in another Co. Code. Basically, it's finished goods AR & AP process. Line items between different Co. Codes some times match and some times NOT. Can anybody please let me know how we can clear these Ven

  • My X200 did not come with a webcam

    I ordered an X200 quite some time ago, maybe in September.  I thought the webcam was standard issue on all X200s, but upon receiving my X200 from Cost Central, to my dismay the webcam was not included.  I didn't mind much and started using it until r

  • FF for Mac began flickering, breaking up the page, repeatedly.

    The question pretty well describes it. I get the page disappearing into multiple colours and pixels, the coming back to the normal page...then flickering again. I'm using version 26 which I believe is the latest for my Mac. I'm on system 10.6.8 on an