Support Board
Date/Time: Tue, 24 Dec 2024 17:08:38 +0000
Post From: ACSIL: using std::map (dictionary) for referring to Subraphs
[2015-10-07 11:55:51] |
User44052 - Posts: 34 |
I’m trying to name my subgraphs so I can refer to them by a name rather than a number. I’m using SCSubgraphRef as described on this page (http://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_scSubgraph.html#scSubgraph) For example, this works fine: SCSubgraphRef bullish = sc.Subgraph[0] ;
My understanding is that it creates a reference, so “bullish” is not an array in its own right, but rather a pointer to the array contained by sc.Subgraph[0]. I hope my understanding is correct. Now, I like using “dictionary” types, or std::map in C++. I want to create a map of references to the subgraphs I’m using, but the following does NOT work: std::map <SCString, SCSubgraphRef> ControlLine ;
SCSubgraphRef ControlLine[“POC”] = sc.Subgraph[1]; SCSubgraphRef ControlLine[“HVN”] = sc.Subgraph[2]; ...etc 1) First of all, why doesn’t the above work? I could only get this to work when I used the following: std::map <SCString, SCFloatArray> ControlLine ; //declared the type as SCFloat Array instead of a Ref
ControlLine[“POC”] = sc.Subgraph[1]; //I had to remove SubgraphRef ControlLine[“HVN”] = sc.Subgraph[2]; //I had to remove SubgraphRef 2) While this does work, I think it uses twice as much memory, correct? My understanding is that ControlLine[“POC”] is actually a copy of Subgraph 1, and ControlLine [“HVN”] is a copy of Subraph 2. so I'm making extra copies of the arrays that already exist. I remember somewhere in the ACSIL documentation discouraged duplicating arrays and creating your own arrays. That part of the documentation recommended that we use references instead. So, my last question: 3) How can I use Subgraph references in an std::map type? Thanks in advance. Date Time Of Last Edit: 2015-10-07 11:57:08
|