|
upper_bound should do the job
Ryan
They read good books, and quote, but never learn
a language other than the scream of rocket-burn.
Our straighter talk is drowned but ironclad;
elections, money, empire, oil and Dad.
|
|
|
|
|
|
I've an in-proc COM object that is registered on the client PC from a network share. An app that uses this COM object running out the same network share shows marked performance degradation (upto 2-3 times slow) when compared to running the same app with the COM object registered locally (the dll was copied to a local drive).
Neither the app nor the the COM object access any files over the network other than some initial setup that happens at load time.
I was expecting a delay only during app load time compared to the local install case, but it turns out that as the network traffic increases, the app starts to lag behind in processing time sensitive events (sometimes upto 20 minutes behind!). Also interesting to note is that as the network traffic reduces, the app starts to catch up & events get handled in timely fashion.
Anybody experienced similar behavior wrt COM objects being registered from a network share? Any insights?
Chen Venkataraman
|
|
|
|
|
I have some code like this
MyClass MyObject;
vector<int> t;
for ( int i=0; i<5; i++)
t.push_back(i+100);
for ( it=t.begin(); it != t.end(); it++)
{
if ( MyObject.GetIntValue() == (*it)
t.erase(it);
}
where i am doing erase operation for current iterator on a vector.
This loop crashes somewhere in
template<class _init,
="" class="" _outit=""> inline
_OutIt _Copy_opt(_InIt _First, _InIt _Last, _OutIt _Dest,
_Nonscalar_ptr_iterator_tag)
{ // copy [_First, _Last) to [_Dest, ...), arbitrary iterators
for (; _First != _Last; ++_Dest, ++_First)
*_Dest = *_First;
return (_Dest);
Any idea what i am doing wrong?
|
|
|
|
|
The problem is that the call to erase invalidates it , so you can no longer use it for the remaining of the loop. Wou can fix this by noticing that vector::erase returns an interator to the following element:
for ( it=t.begin(); it != t.end(); )
{
if ( MyObject.GetIntValue() == (*it)
it=t.erase(it);
else
++it;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, everyone!
Look at the following descriptions from a book,
--------
template <class Key, class T, class Compare = less<Key>,
template <class U> class Allocator = allocator>
class map {
typedef Key key_type;
typedef pair<const Key, T> value_type;
...
};
--------
I do not understand the following starnge C++ grammar,
--------
template <class U> class Allocator = allocator
--------
It really makes me mad!
What does it mean? Who can give me a description?
Thanks in advance,
George
|
|
|
|
|
This is called a template template parameter, i.e. a template parameter which is not a true type, but rather a template (in your particular case, accepting one parameter).
The code is a little strange cause when STL was defined template template parameters weren't part of C++, so STL uses an alternate trick (see allocator::rebind ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddie, my old friend!
George
|
|
|
|
|
Is it safe to use CAtlArray to store an array of structures in a program that just uses Win32 API (we don't use MFC or any other framework). I've tried implementing it and too my surprise it just worked. I'm looking for the catch. Is it safe to re-use the same array repeatedly or will it eat memory each time I use the array.
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
I got an out-of-proc automation server developed using ATL. I want to use it in dialog based MFC application. For this purpose i normally use tlb file to generate class.
Now the problem is that this component fires events and i don't know how to get events fired from control in MFC app. In case of ActiveX control it was easy, as i just right click on control and add event. How can i do so in fore said case ???
|
|
|
|
|
Normally this is done by creating a simple event sink and then using Advise/Unadvise to connect the sink to the object. I'm sure there's an example of this in MSDN.
Steve S
[This signature space available for rent]
|
|
|
|
|
This project http://codeproject.com/wtl/TabbingFramework.asp[^]
uses the Sink Event map and the DispAdvise/UnAdvise.
Look in the HtmlFrame.h
public:<br />
BEGIN_SINK_MAP(CHtmlFrame)<br />
SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_TITLECHANGE, OnTitleChange, &TitleChangeInfo)<br />
SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, OnNavigateComplete2, &NavigateComplete2Info)<br />
SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete, &DocumentCompleteInfo)<br />
END_SINK_MAP()
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
Hi, everyone!
A book said,
--------
a deque supports the constant time execution of these operations
at the end as well as at the beginning.
Insert and erase in the middle take constant time.
--------
I think the insert and rease in the middle algorithm of
STL deque does not take constant time. The time it
taken can be descripted as O(n). (Since deque is stored as a
linked list and not an array.)
I think only an algorithm takes O(1) time should be treated as
"constant time" algorithm.
Am I correct?
Thanks in advance,
George
|
|
|
|
|
I think that is an error in the book. deque is linear insert/remove in the middle according to my stuff.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks, Tim buddie!
George
|
|
|
|
|
Hey all,
Some doubts:
1- How to make a property of an Activex Control(VC++), shows up at the "properties window" in Visual Basic.
2- How to set up the design-time image resource that will be drawn that represents the Control on the form, when the user drag it from the toolbox to the form. I know it's inside the OnDraw() event, isn't it?
Remebering...all without MFC, just ATL.
Raphael Amorim Dantas Leite
VC++, VB, Java, .NET and eMbedded Programmer
|
|
|
|
|
Hi,
1. Look for BEGIN_PROP_MAP documentation. Sample of usage is then:
BEGIN_PROP_MAP(CMyClass)<br />
...<br />
PROP_ENTRY("PropertyName",23, CLSID_NULL)<br />
END_PROP_MAP()
where 23 is a number equal to DispID of your property (simple the id(23) in your IDL in the property definition)
2. For deciding if you are in design mode or runtime mode, use function GetAmbientUserMode( BOOL& bMode ); returning TRUE for run mode and FALSE for design mode.
Hope this is what you meant and that it helps to you
|
|
|
|
|
Thanks a lot geo_m.
But Whenever I drag the component icon from toolbox to the form, in the OnDraw() event is drawn on the form as beveled window with "ATL 3.0 : ComponentName" written over it. I want to put the same icon that is in the toolbox instead of this, got it?
|
|
|
|
|
yep. Then you have to test if you are in the run-time mode or design time mode in the OnDraw (or store the result and only test it here)
If you will be in design time mode, you can draw your icon using DrawIcon method, or any other of your choice.
If you want to know which icon is on the VB toolbar, you can look into your resources, it is stored here, so you can access it and do with it whatever you like.
|
|
|
|
|
Thanks geo_m, you're the man!
|
|
|
|
|
Hi, everyone!
Please look at the following codes,
--------
template <class ForwardIterator>
inline void seq_delete (ForwardIterator first, ForwardIterator last) {
while (first != last) delete *first++;
}
vector<char*> v;
char* c1 = new char[20]; strcpy (c1, "Tim");
char* c2 = new char[20]; strcpy (c2, "Charles");
v.push_back (c1); v.push_back (c2);
seq_delete (v.begin(), v.end() );
// vector v is destroyed at the end of scope
--------
I think that since we use new[], so we should use delete[] other
than delete in the following line.
--------
while (first != last) delete *first++;
--------
Or else, memory leak will occur.
Am I correct?
Thanks in advance,
George
|
|
|
|
|
Yes, you are correct. Since the vector is using what I would call an "unmanaged pointer", the vector has no way of knowing it needs to delete the memory.
For the most part, this is considered bad style since any time elements are removed from the vector, you have to manage the pointers. Thus you have things like boost's ref pointer or stl's string implementation that handles all the management for you. Many times, you can use this "bad style" to your advantage but there is always an associated risk. But like all programming, there are associated risks with everything. It is just a question of managing those risks.
EDIT: I commonly use this "bad style" in situations where the vector is part of another class and is wholly owned by that class. Thus risks are greatly minimized. For the most part, I would never use this "bad style" with something that was directly exposed to other classes or the main program. (i.e. public class members or a global vector.)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi, Tim buddie!
What means
--------
EDIT: I commonly use this "bad style" in situations where the vector is part of another class and is wholly owned by that class. Thus risks are greatly minimized. For the most part, I would never use this "bad style" with something that was directly exposed to other classes or the main program. (i.e. public class members or a global vector.)
--------
in your reply, can you show me an example?
I found the examples are better to make oneself understood when
expressing thoughts. I am a newbie.
Thanks in advance,
George
|
|
|
|
|
Trying to think of a simple one... *thinking*
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi, Tim buddie!
What is your meaning? I can not get your ideas?
Thanks in advance,
George
|
|
|
|