translate "static map" to Delphi?

There doesn't appear to be an equivalent language sub-forum in the Delphi section so I'll ask this here. It sort of fits: The original is C++.

I'm trying to port some C++ code to Delphi and I am stymied by the map statement/command/whattheheckthatis.

At one point they declare{code}static map<int,somename*> *someothername;{code}then later they use this in a procedure declaration:{code}procedure someproc(somename *someparam){code}Later I see this:{code}someothername->erase(somevalue);{code}

I'm looking at all this and wondering how the heck this translates into the world of Delphi. Did some searching on map to figure out what exactly it is doing, but most explanations seem written with the assumption you already understand it. The official documentation is even worse.
0
Doug
4/2/2014 1:24:16 PM
embarcadero.cppbuilder.cpp 2803 articles. 0 followers. Follow

3 Replies
632 Views

Similar Articles

[PageSpeed] 48

Doug wrote:

> There doesn't appear to be an equivalent language sub-forum in the
> Delphi section

Yes, there is:

Web: https://forums.embarcadero.com/forum.jspa?forumID=89
NNTP: embarcadero.public.delphi.language.delphi.general

> At one point they declare
> {code}static map<int,somename*> *someothername;{code}
> then later they use this in a procedure declaration:
> {code}procedure someproc(somename *someparam){code}

Is it declared as a global variable, or as a member of a class/record?  It 
makes a difference in how it is translated.

> Later I see this:
> {code}someothername->erase(somevalue);{code}
> 
> I'm looking at all this and wondering how the heck this translates
> into the world of Delphi.

The closest thing to std::map in Delphi is the System.Generics.Collections.TDictionary 
class.

For example, using a global variable:

{code}
uses
  ..., System.Generics.Collections;

type
  psomename = ^somename;
  somename = ...;

var
  someothername: TDictionary<Integer, psomename>;

....

initialization
  someothername := TDictionary<Integer, psomename>.Create;
finalization
  someothername.Free;
{code}

Or, using a class member:

{code}
uses
  ..., System.Generics.Collections;

type
  psomename = ^somename;
  somename = ...;

  someclass = class
  public
    class var
      someothername: TDictionary<Integer, psomename>;
  strict private
    class constructor Create;
    class destructor Destroy;
  end;

....

class constructor sometype.Create;
begin
  someothername := TDictionary<Integer, psomename>.Create;
end;

class destructor sometype.Destroy;
begin
  someothername.Free;
end;
{code}

> Did some searching on map to figure out what exactly it is doing

Basically, it is a lookup table, where the first parameter specifies the 
data type used to identify items, and the second parameter specifies the 
data type of the items that are being identified.  Thus, map<int,somename*> 
is a list of somename* pointers that are identified by int values.

--
Remy Lebeau (TeamB)
0
Remy
4/2/2014 6:04:14 PM
Thank you muchly. I'll look into this.
0
Doug
4/2/2014 6:19:11 PM
Doug wrote:

> Thank you muchly. I'll look into this.

See:
http://docwiki.embarcadero.com/Libraries/XE5/en/System.Generics.Collections.TDictionary

--
Remy Lebeau (TeamB)
0
Remy
4/2/2014 6:27:18 PM
Reply:

Similar Artilces:

Precedence of "where" ("of", "is", "will")?
Nobody on #perl6 today could answer this one. Is: Str | Int where { $_ } the same as: (Str | Int) where { $_ } or: Str | (Int where { $_ }) ? Followup questions, Mr. President: What kind of operators are "where", "of", "is", and "will"? Is there a reason that S03 doesn't list them? What are their precedence(s)? -- Chip Salzenberg - a.k.a. - <chip@pobox.com> Open Source is not an excuse to write fun code then leave the actual work to others. Chip Salzenberg writes: &...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD 9.0.0.580. Bruce "Bruce Lamb" <lamb.bruce@mayo.edu> wrote in message news:6HgI315nCHA.155@forums.sybase.com... > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

Hyperlink with "map" and "area"
Hi All,I am currently evaluating DNN for our intranet. I would like to migrate our .NET based current site to a DNN architecture. Our graphics department has developed the site with background image representing the menu and each menu item is positioned with html code like this one:<map name="Map"><area shape="circle" coords="303,125,31" href=http://www.oursite.com/fonction.asp>etc...this is positioning hyperlink at arbitrary position and shape. Currently, we have 9 circle shape arranged in circle. I wonder, can this be easily adapted to DNN? For example, I would have to ass...

quotes, quotes, quotes...
I am getting this error and I know what is causing it, but I have no idea how to fix it, any help would be great. The script steps through the /var/log/messages file on a linux server and puts The entries into a mysql database. However when it gets to the 'hlt' line in the messages file it just barfs. The single quotes are freaking it out. I know about quotes but not how to use in this situation. Thanks, Paul Error: May 27 17:53:00 localhost kernel: Checking 'hlt' instruction... OK. <----- doesn't like this in the messages file DBD::mysql::st exec...

I need to translate "today" of the "CalendarExtender"
I am Brazilian and I need to translate my "CalendarExtender" for Portuguese. But "Today" Only is in English I Executed the Download of the ToolKit in September of 2007. if I to execute download again now, this error will be corrected??   thanks!!! In the ScriptManager control, set the attributes EnableScriptGlobalization and EnableScriptLocalization both to true.  Then it should be able to use page language settings.Christopher Reed"The oxen are slow, but the earth is patient." these properties already are adjusted       &n...

Translation question: "Wiedervorlage" = "resubmission"?
Hi. Before asking a "best practice" question in the GW8 Client forum: I'm not sure, what's the correct English translation for the German term "Wiedervorlage" ? (re-read email at a certain date) Regards, Rudi. Rudolf Thilo wrote: > Before asking a "best practice" question in the GW8 Client forum: > > I'm not sure, what's the correct English translation for the German > term > > "Wiedervorlage" ? (re-read email at a certain date) Google Translate says resubmission. Don't question Google...

"Using" or "With"
Hi all Please can someone enlighten to me as regards the difference with the "Using" and "With" statement when accessing data - which is better, what are the limitations and/or any pointers. Many thanks. Regards DaveDavid WinchesterPlease mark as answer if this is the solution.  using gives you the ability to use the connection and it closes the connection directlly after you finish using it. and there is no need to try- cach - finaly. there is no limitation on using USING keywordMuhanad YOUNISMCSD.NETMy Blog || My Photos || LinkedIn I have a dataobject the re...

Replacing "\\" with "\"
Hi all I'm getting this value from a CheckBoxList control - a location of file, i have to remove "\\" and replace it with "\" and pass it to Query, how to do it, i tried with Replace, but coud'nt suceed. "\\\\Blaze10xp\\BLZ_SFS_07\\Sample Excel Files\\Excel Files\\report2.xls" thank's in advance - Prakash.C you tried Replace like this? string newstring = oldstring.Replace(@"\\",@"\");Plese, do not forget to click "Mark as Answer" on the post that helped you. Thanx!My blog: Scenes From A Developer Memory yes i tr...

"To" and "From" missing
When I print emails, the words "To" and "From" are blank, even though the "To" name and "From name (addresser, addressee) do show up. This is not a problem for other users on my system. Suggestions In mailbox right click, view. On the message window, right click and choose print options. Make sure print header is checked. -- Barry Merchant NSC Volunteer SysOp *** no email unless requested please!! *** > In mailbox right click, view. On the message window, right click and > choose print options. Make sure prin...

"-" not "_"
I wrote a SQL statement in the data tab. I wrote a bunch of alaises as example ' word-type ' but when I hit the layout tab it converts the "-" to "_". So now my field name is ' word_type '. Is there any way to prevent this? CardGunner Don' use a hypen ( - ).  It isn't a valid character for column names.   See http://searchsqlserver.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid87_gci1188931,00.html   Here's an excerpt about column names: Letters as defined in the Unicode Standard 2.0 Decimal numbers from either B...

replace the "." with a ","
Oi.... I need to build a small programm in ASP.NET and chose to use C# for it.Now i got everything working but there's one little problem.the first textbox is a double. I need to make it so that when someone enters a "." then it gets replaced by a ","any ideas?Ghan  string blah = "4.2.2.2";blah = blah.Replace(".", ",");Ryan Ryan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question...

double quote
hello there...  i tried everything of think but not working the way i wanted to be... not sure what i'm missing...i'm generating a <span> in code behind and then using in javascript.... here is what i'm doing code behind: int i=0string _keywordID = "keyword";string _name = row["visit_info_nm"].ToString().Trim(); String _getElementByID = String.Format("<span id='{0}' OnClick = \"document.getElementById('{1}').value='{2}';\">{3}</span><br>", i, _keywordID, _name, _name); here is what it generate : <span id='1' OnClick = \"document.getElementById('keyword')...

"Me" is better than "You"
Yes I know, strings are frozen. But let me talk about it, I really can't get through the idea of a PC talkin to me. I consider my PC as an extension of myself, not a dumb companion who addresses Me as You. Yes there are times when I get angry with Him while I work and get wrong calculations etc.., but it really is my fault, Me using wrong istructions and eventually wanting to find someone else to blame, but it's Me. And yes, I consider Thunderbird my mail program, reading my mail on my PC as Me. So I personally like to have Me in the header bar as a compact address ...

Using "+" or "||"
Using SQLAnywhere 5.5.04, I've gotten into the habit of using "||" in ISQL to indicate a string concatenation. I needed to paste my SQL statement into the PowerBuilder script painter for some embedded SQL, and PB didn't like the "||" very much at all. I changed it to "+" and it seems to be ok. Do these two operators indicate ~exactly~ the same thing? moin, afaik these two's are not the same! if you're using "||" and any term is NULL then in the resultstring the term will be ignored if you use "+" then the resu...

Web resources about - translate "static map" to Delphi? - embarcadero.cppbuilder.cpp

Resources last updated: 1/28/2016 6:49:29 PM