Results 1 to 6 of 6

Thread: Index table as String

  1. #1
    Join Date
    Dec 2009
    Posts
    178

    Index table as String

    Hello,
    Is it possible to declare an array whose indexes are strings?
    example:
    Code:
    tab [ "name"] = 0.45, tab [ "first_name"] = 0.66, ..., array [address] = 0.7
    Is it possible to have a couple (String1, string2) as an index?
    example:
    Code:
    tab [(name, surname)]: = 0.9, ...
    Except that you propose as a solution to replace the index String? Thank you
    Last edited by New ID; 13-01-2010 at 02:16 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Index table as String

    Hello,
    In Java an array is necessarily numbers as clues. To do what you want you can use a hashmap (this is a data structure that can associate a key (index) to a value). You use it like this
    Code:
    HashMap map = <String,Float> new HashMap <String,Float> ();
    map.could("name",0.45);
    map.could("firstname",0.66);

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Index table as String

    Hello,
    No tables can be String indices but is not very serious because you can use Maps to do the same thing. A small example with String key and value Double.
    Code:
    import java.util.Map;
    import java.util.HashMap;
     
    ...
     
    Map<String, Double> map = new HashMap <String, Double>(); / / declaration of the Map
    map.could("name", 0. 45); / / add the value 0.45 with the key "name"
    int value = map.get("name"); / / get value

  4. #4
    Join Date
    Dec 2009
    Posts
    178

    Re: Index table as String

    Actually I manipulate a matrix whose column indices are d = couples strings and integers:

    (34175, "string1") (34175, "string2") ... (34175, "MOTP)
    0............ 0.56............ 0.21..................... 0.33
    1
    2
    .
    .
    .
    n. ........... 0.99 ............ 0.11 ..................... 0.44

    How to report and handle all that? Thank you

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Index table as String

    Hello,
    I think you can try out this.
    1. you define your index couple string / integer in a class immutable
    2. you override the equals and hashcode for this class
    3. then then use instances of this class as HashTable key (for ex.).

  6. #6
    Join Date
    Dec 2009
    Posts
    178

    Re: Index table as String

    Hello,
    For the structure is ok. it is just a detail, I want to make a
    Map <Torque, int> Map1 = new HashMap <Couple int>();
    not
    Map <Couple Double> Map1 = new HashMap <Couple Double>();
    I want to use the int as an index of the table. Because it does not Double as an ind

Similar Threads

  1. Word 2007 Error "TABLE INDEX CANNOT BE ZERO"
    By Reputator in forum Operating Systems
    Replies: 5
    Last Post: 20-05-2011, 10:29 AM
  2. Link a Table to another Table to Drop Down In Main Table
    By himeshRES in forum Windows Software
    Replies: 6
    Last Post: 11-12-2010, 02:01 PM
  3. Does Google decides which content to index & what not to index?
    By Uddhav in forum Technology & Internet
    Replies: 5
    Last Post: 04-03-2010, 07:37 PM
  4. Inserting an index entry into index 0 of file 25
    By Dharmesh Arora in forum Operating Systems
    Replies: 3
    Last Post: 16-07-2009, 10:10 AM
  5. Replies: 3
    Last Post: 07-07-2009, 08:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,577,845.18660 seconds with 16 queries