Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Associative Array



Permlink Replies: 5 - Last Post: Jan 9, 2018 11:22 PM Last Post By: sharon maxwell
Chris Woodhouse

Posts: 5
Registered: 2/9/00
Associative Array
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 19, 2017 5:54 AM
Is there really no way to do an Associative Array with C++ Builder? It seems unordered maps don't work with mobile apps. TDictionary can't be implemented in C++ if you don't also have Delphi. Is there something else I haven't found?

Chris W.
Chris Woodhouse

Posts: 5
Registered: 2/9/00
Re: Associative Array
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 19, 2017 9:09 AM   in response to: Chris Woodhouse in response to: Chris Woodhouse
Never Mind it seems I just had to uncheck "use 'classic' Borland compiler" option and unordered maps work fine now.

Edited by: Chris Woodhouse on Dec 19, 2017 9:09 AM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Associative Array [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 19, 2017 11:55 AM   in response to: Chris Woodhouse in response to: Chris Woodhouse
Chris Woodhouse wrote:

Never Mind it seems I just had to uncheck "use 'classic' Borland
compiler" option and unordered maps work fine now.

std::unordered_map was added in C++11. The "classic" Borland compiler
does not support C++11, only the Clang-based compilers do.

--
Remy Lebeau (TeamB)
Burkhard Schlimme

Posts: 2
Registered: 3/28/06
Re: Associative Array [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 5, 2018 10:34 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Chris Woodhouse wrote:

Never Mind it seems I just had to uncheck "use 'classic' Borland
compiler" option and unordered maps work fine now.

std::unordered_map was added in C++11. The "classic" Borland compiler
does not support C++11, only the Clang-based compilers do.

--
Remy Lebeau (TeamB)

For the classic compiler you can use boost::unordered_map or std::tr1::unordered_map.

Edited by: Burkhard Schlimme on Jan 5, 2018 10:35 AM
sharon maxwell

Posts: 3
Registered: 2/10/18
Re: Associative Array [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2018 11:21 PM   in response to: Burkhard Schlimme in response to: Burkhard Schlimme
GHashTable *table=g_hash_table_new(g_str_hash, g_str_equal);

/* put */
g_hash_table_insert(table,"SOME_KEY","SOME_VALUE");

/* get */
gchar *value = (gchar *) g_hash_table_lookup(table,"SOME_KEY");

http://www.cetpainfotech.com/technology/c-language-training
sharon maxwell

Posts: 3
Registered: 2/10/18
Re: Associative Array [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2018 11:22 PM   in response to: Burkhard Schlimme in response to: Burkhard Schlimme
GHashTable *table=g_hash_table_new(g_str_hash, g_str_equal);

/* put */
g_hash_table_insert(table,"SOME_KEY","SOME_VALUE");

/* get */
gchar *value = (gchar *) g_hash_table_lookup(table,"SOME_KEY");

http://www.cetpainfotech.com/technology/c-language-training
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02