CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

OpenFOAM equvalent to std::map

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 11, 2014, 13:26
Default OpenFOAM equvalent to std::map
  #1
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi,

I want to achieve something like this
Code:
std::map<std::string, MyClass*> variablesTable;
for ( i=1 ; i <= NumberOfObjects ; i++)
{
    std::ostringstream oss << "name" << i;
    variablesTable[oss.str()] = new MyClass();    
}
As you can see the code should create a number of objects where the number depends on the variable "NumberOfObjects" and save these in a "map" (container) where the objects can be accessed by a key string later on.

Is there any OpenFOAM class I can achieve the above with or will I have to use class "std::map"?

greetings
maybee
maybee is offline   Reply With Quote

Old   February 11, 2014, 14:55
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Code:
alexey at daphne in HashTables$ pwd
$FOAM_SRC/OpenFOAM/containers/HashTables

alexey at daphne in HashTables$ ls -1
HashPtrTable
HashSet
HashTable
Map
PtrMap
StaticHashTable
I guess you need HashPtrTable.
alexeym is offline   Reply With Quote

Old   February 11, 2014, 16:05
Default
  #3
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
Thx for this extensive list
maybee is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 3 November 14, 2023 11:58
[Gmsh] 2D Mesh Generation Tutorial for GMSH aeroslacker OpenFOAM Meshing & Mesh Conversion 12 January 19, 2012 03:52
Problem installing OpenFOAM 1.5 installation on RHEL 4. vwsj84 OpenFOAM Installation 4 April 23, 2009 04:48
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07
OpenFOAM Training and Workshop Hrvoje Jasak Main CFD Forum 0 October 7, 2005 07:14


All times are GMT -4. The time now is 23:45.