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

OpenFOAM equvalent to std::map

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 11, 2014, 14:26
Default OpenFOAM equvalent to std::map
  #1
Senior Member
 
Join Date: Jan 2012
Posts: 159
Rep Power: 5
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, 15:55
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,133
Rep Power: 20
alexeym will become famous soon enoughalexeym will become famous soon enough
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, 17:05
Default
  #3
Senior Member
 
Join Date: Jan 2012
Posts: 159
Rep Power: 5
maybee is on a distinguished road
Thx for this extensive list
maybee is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 0 January 1, 2014 20:21
2D Mesh Generation Tutorial for GMSH aeroslacker Open Source Meshers: Gmsh, Netgen, CGNS, ... 12 January 19, 2012 04: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 14:11.