|
If your looking for a little more speed on the lookup, you could use a 'set', as it will be pre-sorted. Only thing is there is an increased overhead in loading the items.
Of course a 'set' is for unique values. If you require the abbility to store duplicates then you could use a 'multiset'.
All you need to do then, is find the value you are looking for or the nearest one, and search one place in the correct direction.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
|
Note the use of reverse iterators and binders.
vector<int> v;
vector<int>::reverse_iterator iter;
iter = find_if(v.rbegin(), v.rend(), bind2nd(less<int>(),250));
|
|
|
|
|
|
Dear all,
I have two template functions for displaying books and members respectively from arrays.
<br />
template<class Object><br />
void List<Object>::displayBook(char* type)<br />
{<br />
if (num_elements == 0)<br />
cout<<"No "<<type<<" is found in the "<<type<<" array.\n";<br />
else<br />
for(int element=0; element<this->num_elements; element++)<br />
{<br />
cout<<'\n';<br />
this->element_list[element]->display(association_list.get_member(element_list[element]));<br />
}<br />
}<br />
<br />
template<class Object><br />
void List<Object>::displayMember(char* type)<br />
{<br />
if (num_elements == 0)<br />
cout<<"No "<<type<<" is found in the "<<type<<" array.\n";<br />
else<br />
for(int element=0; element<this->num_elements; element++)<br />
{<br />
cout<<'\n';<br />
this->element_list[element]->display(association_list.get_book(element_list[element]));<br />
}<br />
}<br />
The function prototypes are:
<br />
Member* get_member(Book* book);<br />
Book* get_book(Member* member);<br />
and the functions implementation code is:
<br />
template<class Book,class Member><br />
Member* AssociationList<Book,Member>::get_member(Book* book)<br />
{<br />
Member* member=0;<br />
bool searching=true;<br />
int index=0;<br />
<br />
while(searching)<br />
{<br />
if (this->association_list[index])<br />
if (this->association_list[index]->linked_book()==book)<br />
{<br />
member=this->association_list[index]->linked_member();<br />
searching=false;<br />
}<br />
else<br />
index++;<br />
else<br />
index++;<br />
if (searching && (index == LIST_SIZE))<br />
{<br />
searching=false;<br />
}<br />
}<br />
return member;<br />
}<br />
<br />
template<class Book,class Member><br />
Book* AssociationList<Book,Member>::get_book(Member* member)<br />
{<br />
Book* book=0;<br />
bool searching=true;<br />
int index=0;<br />
<br />
while(searching)<br />
{<br />
if (this->association_list[index])<br />
if (this->association_list[index]->linked_member()==member)<br />
{<br />
book=this->association_list[index]->linked_book();<br />
searching=false;<br />
}<br />
else<br />
index++;<br />
else<br />
index++;<br />
if (searching && (index == LIST_SIZE))<br />
{<br />
searching = false;<br />
}<br />
}<br />
return book;<br />
}<br />
Could someone tell me how can I use One Template Function Instead of Two (if this is possible)?
Apologies for posting the similar question many times.
grscot
|
|
|
|
|
try implement func^n overloading/overriding
|
|
|
|
|
I'm looking for an editor which I can use for C or C++ application compiled from command prompt with build.exe or nmake.exe utility.
It is difficult for me to use the MSDEV.EXE.
Thank you in advance,
Seval YILMAZ
|
|
|
|
|
|
I am using VC7, non-MFC
I have two DateTimePicker controls in a dialog box
one to display Time and one to display Date(ShortDate)
The my main problem is I CAN NOT DISPLAY ANY TIME OR ANY DATE I WANT => they always only display current time and current date
such as:
now = 05:57:00 PM Wed 30th, April 2003
so, they display as "05:57:00 PM" and "30-04-2003"
If I want them display as "02:12:53 PM" and "03-03-1990"
How can I do to obtain the correct results ??????
thank alot!!!!!!
and how to change "02:12:53 PM" to "14:12:53" format ???
|
|
|
|
|
Have you looked at any of the following messages:
DTM_SETFORMAT
DTM_SETSYSTEMTIME
|
|
|
|
|
that is DTM_SETSYSTEMTIME
thank
it's my mistake >> i dont check return value
thank you
|
|
|
|
|
Hi all,
I need to implement a small editor using syn.-coloring and multiple undo/redo actions.
Syn.-coloring works fine for riched32.dll, but this does not support multiple undo/redo.
1.
Richedit 2.0 supports undo/redo, but there is a strange diffrence between RE 1.0 and 2.0 which causes problems with my coloring function. Version 1.0 translates CR/LF pairs into one '\n', when copying the contents of the control into a CString, Version 2.0 does not (leaves the pairs, so there are to chars in the CString). That of course confuses the syntax coloring when using diffrent versions. Has anybody an idea to work around this diffrence without version checking of the RE versions?
2.
Does anybody know if there is a possibility to prevent coloring and selection actions inside the RE 2.0 control from being recorded into the undo/redo buffer? I just want to record typing actions.
Thanks for replies,
Giovanni
|
|
|
|
|
Search codeproject for 'syntax color'. There is an article call some thing like [syntax colored code viewer] which uses Rich edit.
Sorry I did not have time to look it up for you. My manager has a bug report to make.
|
|
|
|
|
hi,everybody.
I edit contents by using RichEdit control.(font size, color, etc...)
When send it through smtp sever, received mail is different from edited contents.
Sending or Receiving mail have no problem.
How do I process edited contents?
now, I read edited contents by CString variable. and make it MIME...
|
|
|
|
|
Hello friends ,
I am doin a MFC project .In that i launch an application using shellexecute () ...NOw i have a question .
1.If i use ShellExecuteEx ,i can get the handle of the process .But how do i get the handle of that window associated with the process....for example if i launch a mpeg file ,the windows media player opens.Now how do i get the handle of the media player window????
|
|
|
|
|
Use CreateProcess() to easily retrieve the windows handle
~RaGE();
|
|
|
|
|
Hi there
If (when) my application crashes I perform a minidump and notify the user that something bad happened. In the user notification I would like to be able to present the contents of the minidump, in a human readable format. As I see it, the interpretation of the minidump file can be implemented through the use of MiniDumpReadDumpStream.
Out of laziness I just want to hear if anyone has some code, which takes a minidump file and interprets is, before I start implementing it myself.
Thanks in advance
Riverwind (DK)
|
|
|
|
|
I am using winpcap for sending packets.The problem I am getting is that the packet goes out in the network line but does not reach its destinaion.
I am 100% sure that the source and destination ip and mac addresses are alright.
I am using cross cable between systems having platforms win2000 server(source) and winxp professional(destination).
Ips are 192.168.2.64(Source) and 192.168.2.63(desination) with subnet mask of both (255.255.0.0).
I have tried all the possibilites but it has not happened .
I am realy desperate.
Why?
Reply me soon
|
|
|
|
|
Well, looking at it fast I would use subnet mask (255,255,255,0)
on both computers, with allows them to be peers.
jhaga
|
|
|
|
|
Hello,
I have a ListBox control wich displays several strings. I want now to make some string more "visible" than other. For example, make a string bold, or color the text or color the background of the specified string.
How can I do this in a simple way ? Any idea?
Thanks
|
|
|
|
|
You'll need to make the control Owner Draw, then provide the code to draw your list items appropriately.
There are quite a few examples of owner draw list boxes here http://www.codeproject.com/combobox/[^]
|
|
|
|
|
Hi,
Is there any (legal) method to tell Windows where the .inf and other driver files for a certain device are?
I have to include driver (.inf and .sys) in an installation, and currently, the user has to browse for the .inf file on request of the driver wizard. I'd like to "skip" this step (as it is usually for an already-installed driver) if possible.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Has anyone ever encountered a crash when doing a StepOver in the debugger in VC6? VC6 just all of a sudden dies and closes. It seems the problem is getting worse and worse, and I haven't seen it on any other project but ours. Has anyone else seen this problem, and if so, any workarounds?
Thanks!
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
I think back on Win9x I used to see this, but not on W2K or WXP. What version of Windows are you using?
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Windows Xp Pro
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|