|
Stuart Dootson wrote: the fundamental property of iterators of associative containers is that they iterate through the containers in the nondescending order of keys where nondescending is defined by the comparison that was used to construct them.
Yes, this used to be a problem for us when we really didn't want the map to behave so.
But not aware that an unordered one exists.! thanks.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
[edit]Modified code after actually building and running it...[/edit]
There are lots of ways of doing this. I wouldn't use a set, 'cause it's generally quicker to use a sorted std::vector and then do a std::lower_bound or std::upper_bound to find the relevant item.
What I'd do (have done!) would be to make a secondary index, which is a vector of Info pointers and sort it.
bool OrderOnDistToRef(Info const* l, Info const* r) const { return l->DistToRef < r->DistToRef; }
std::vector<const Info*> index;
for(std::map<LONG, Info>::const_iterator i=m_PtsInfo.begin();i!=m_PtsInfo.end();++i)
{
index.push_back(&i->second);
}
std::sort(index.begin(), index.end(), OrderOnDistToRef);
Then we can do lookups using something like
Info lookingForStruct;
lookingForStruct.DistToRef = distToRefWeAreLookingFor;
std::vector<const Info*>::const_iterator found = std::lower_bound(index.begin(), index.end(), &lookingForStruct, OrderOnDistToRef);
Alternatively, you could use a Boost Multi-Index[^], which gives you a mappish container with multiple lookups.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Tuesday, February 17, 2009 4:17 PM
|
|
|
|
|
I need it when writing an algorithm, but surprisingly it is there.
|
|
|
|
|
You could implement something like the following to get the same functionality
string s;
try
{
s.at(s.size() - 1)
}
catch (exception& e)
{
}
«_Superman_»
|
|
|
|
|
The most flexible way to get that functionality is probably a function like this
template<class StringType>
typename StringType::value_type back(StringType const& s)
{
return *s.rbegin();
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
How do we Inherit struct from another struct in IDL file
|
|
|
|
|
Hi,
I have Add In developed in ATL COM which will take care of open, close etc...events. I am able to get the events for Word 2007 but when I am using perticular cell in Excel 2007 and my cursor is in the same cell I wont be able to get name of the excel file. Since my cursor is in cell then I wont get file activate event.
I would like to know how to get the name of excel file even if my cursor is in cell (note:- cell is not selected. cursor is present in the cell)
Thanks
SNI
|
|
|
|
|
Hi,
I am using the ATL COM DLL. In this I am createng two threads.
I have added new ATL object which supports connceting point, appartment thereaded model,
Dual interface and agregation=yes. While creating thread and passing the interface pointer as this pointer.
hStatusThread = CreateThread(NULL,
o,
LPTHREAD_START_ROUTINE(StatusThread),
(LPVOID)this,
0,
&dwThStId);
::SetThreadPriority(hStatusThread, THREAD_PRIORITY_HIGHEST);
I am accessing the interface pointer in thread and firing the event..
UINT StatusThread(LPVOID param)
{
CMyConnectObj *ptrObj = NULL;
ptrObj = (CMyConnectObj*)param;
if(ptrObj == NULL)
return 0;
if(WaitForSingleObject(g_Mutex,INFINITE) == WAIT_OBJECT_0)
{
ptrObj->Fire_ErrorCode(lErrorCode);
ReleaseMutex(g_Mutex);
}
}
I am using vb6.0 client to use this dll.
but while firing event at line i
ptrObj->Fire_ErrorCode(lErrorCode);
it's giving error as "Unhandled Exception in ConnectProg.exe (MSVBVM60.dll)0x0000005: Access Violation.
But if I tried to fire event for one of the ATL object function there is no problem at all.
Please help me for this with perect solution..
It's very urgent.
|
|
|
|
|
chetanjoshi9 wrote: THREAD_PRIORITY_HIGHEST
That's a bit evil for a start - you really don't want to be altering thread priorities.
chetanjoshi9 wrote: MSVBVM60
That's likely your problem - your contorl might be thread aware, but I don't think VB6 is...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
what is mean by thread aware?
|
|
|
|
|
Your control is aware that there can be more more than one thread, and deals with that. Visual Basic doesn't.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
please tell me the settings required while creating the new ATL object if we want to fire event within the thread....
|
|
|
|
|
First thing to try - you need to call CoInitializeEx[^] on the StatusThread, that way your event firing might be marshalled across into the VB thread.
Otherwise...have you thought about firing the event on the other thread, you know, the one VB calls?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hStatusThread = CreateThread(NULL,
0,
LPTHREAD_START_ROUTINE(StatusThread),
(LPVOID)this,
0,
(LPDWORD)&dwStID);
::SetThreadPriority(hStatusThread, THREAD_PRIORITY_HIGHEST);
UINT StatusThread(LPVOID param)
{
MSG msg;
CMyTestObj *ptrObj = (CMyTestObj*)param;
while(1)
{
if(!GetMessage(&msg, NULL, 0, 0))
return 0;
switch(msg.message)
{
case START_COMMAND:
ptrObj->Fire_ErrorCode(123);
break;
}
}
}
This is my code
I am firing event in thread as
PostThreadMessage(dwStID, START_COMMAND, NULL, NULL);
but application crashes at line "ptrObj->Fire_ErrorCode(123);"
But if fire event in any member function (without thread) it works fine..
Please help me for this..
it's very urgent
Thanks.
|
|
|
|
|
No, that's not what I said, is it. Did I say something about adding a CoInitializeEx to StatusThread? Yes, I think I did. Try that first, it may enable the COM runtime to marshall the event fire across to the VB thread.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
please tell me how to use CoInitialzeEx() on StatusThread..
I am not getting....
Please...
|
|
|
|
|
Go away and learn about how COM and threads interact[^]. You need to understand this stuff before you try messing with COM and threads.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am relatively new to ATL/WTL. I am writing an application in VC++ using ATL/WTL (not using MFC).
I need to write helper classes for my application that will
- Write all the log information in the form of proper XML files. I need to follow a valid/standard schema with XSLT for writing the XML data.
- Parser to read the XML files using the above schema & iterate through the nodes.
I have never worked with XML before and I am only trying to use ATL/WTL with VC++, so I would greatly appreciate if anyone can instruct me on how I can go about implementing this, for example - point me to the right classes for implementing a XML wrapper for writing data in XML files & for parsing the XML files and iterating through the nodal data. Some sample code would also be very helpful for me in this regard.
modified on Monday, February 9, 2009 8:21 AM
|
|
|
|
|
ATL's not going to help you much - it doesn't have any XML classes. I would use MSXML[^], I guess. You could use ATL smart pointer and BSTR wrapper classes.
Rennie76 wrote: I need to follow a valid/standard schema with XSLT for writing the XML data
XML Schemas are XSD, not XSLT - XSLT is for transforming XML from one format to another.
|
|
|
|
|
Stuart Dootson wrote: I guess. You could use ATL smart pointer and BSTR wrapper classes.
Yes, I would not use MSXML without the ATL #import code. Also _com_error , _bstr_t , _variant_t
|
|
|
|
|
|
As already mentioned there is MSXML and also XMLLite.
Rennie76 wrote: Some sample code would also be very helpful for me in this regard.
Both are documented on the msdn web site and I imagine sample code is available there as well.
|
|
|
|
|
led mike wrote: XMLLite
Ooooh - I'd forgotten about that one. Nice reminder.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
When creating an ATL COM project and adding an ATL Simple Object, if I create a method for that class that has one [in] BSTR parameter and one [out,retval] BSTR* parameter...
What can I assume or assert about the retval in this circumstance? In other words, do I need to check the BSTR to ensure that it does not already point to something and deallocate it if I decide to set the value? Is it mandatory to set the BSTR's value to something?
STDMETHODIMP CSomeATLClass::SomeATLClassMethod(BSTR bstrIn, BSTR* retVal)
{
return S_OK;
}
modified on Thursday, February 5, 2009 3:04 PM
|
|
|
|