|
Hey everyone,
I need a map class to represent the data in a sort of network class I'm making and I've been looking at Boost graph library for this. The one feature I really need is the ability to join two graphs together, by specifying a vetex from each that should be joined with an edge. Although Boost::mutable_graph looks close to what I want, I don't see how I can implement my join/union/addition operation in an efficient manner with the boost graph operations. Does anyone have experience with this problem and know of any potential solutions for it? Any suggestions for libraries that might work? I am going to check out the Graph Template Library and see if that might support this better. I could always make a graph structure that is optimized for my operation, but that would probably take more time than just finding something preexisting that just works.
Any suggestions?
|
|
|
|
|
A rough guess:
map1[0,1] = ?
map1[0,2] = ?
...
map2[0,1] = ?
map2[0,2] = ?
...
join(map1,map2);
new_map1[0,1] = ?
new_map1[0,2] = ?
...
Possible Solution:
void shift_keys(map_type& map, map_type::size_type amt)
{
map_type new_map(map);
map_type::iterator mi = map.begin();
for( ; mi != map.end(); ++mi )
new_map[std:make_pair((mi->first).first+amt,(mi->first).second+amt)]
= mi->second;
map.swap(new_map);
}
vod join(map_type& map1,map_type& map2)
{
map_type new_map(map2)
shift_keys(map2,map1.size());
map_type::iterator mi = new_map.begin();
for( ; mi != new_map.end(); ++mi )
map1[mi->first] = mi->second;
}
This is an incomplete solution (off the top of my head). It should successfully join the two maps.
Example:
join(map1,map2);
map1[0,1] = ?
map1[0,2] = ?
..
map1[2,3] = ?
map1[2,4] = ?
...
I hope that helps you figure out the problem. Maps allow only one entry per-key; therefore, you have to change any key values in map2 that may be the same as a key values in map1 before you attempt to join them.
It may be more complicated than that, but I have essentially used simular code to join two maps.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I want to create command buttons dynamically in an dialog based application - is this possible?
Ger
|
|
|
|
|
Ger Hayden wrote:
is this possible?
Yes, Just make sure the ID's you assign the buttons are within a certain range and use the ON_CONTROL_RANGE macro to map your buttons to a handler function.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Handlers_for_Message.2d.Map_Ranges.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I have a button in an application. The user has to click that
button first to pop up a dialog box and get started. So I have
the text on the button that says 'Click here first'. But people
dont see the button.
So I made the button a hover button, so that it looks hot when
you hover over. But people still miss the magic button.
My question is, is there a way to make a button blink alittle
(not alot so that its annoying)? Just a light blink on occasion
to catch the user's eye.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Start a timer (see CWnd::SetTimer ) with handler value of NULL and create a message handler for WM_TIMER, you can do the colour control etc. there.
Elaine
The tigress is here
|
|
|
|
|
using SetTimer() is the right manner to set a blinking effect.
but can i suggest you to disable the other buttons if only this one should be clicked ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Rule #1 of UI: Users don't read.
If the only way to start is to click the button, why do you make the user click it? Just start whatever it is the app does.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
What is wrong with this?, how can I use this to make it work?
CString sDriveLetter= (TCHAR) (i + ('A'));
This is the error I get;
cannot convert from 'TCHAR' to 'ATL::CStringT<basetype,stringtraits>'
|
|
|
|
|
What is the error number (C####) that the compiler gave you? If you look up that error number in MSDN you can usually figure out what the problem is by reading the explanation provided.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
CString sDriveLetter;
sDriveLetter.Format("%c", (TCHAR) (i + ('A')));
Tom Archer
Visual C++ MVP
|
|
|
|
|
Unless MFC CString class varies from STL, that would be Illegal.
CString sDraveLetter = _T('A');
CString sDraveLetter = _T("A");
CString sDraveLetter;
sDraveLetter = TCHAR(i+_T('A'));
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I am having a little problem handling Threads. Problem is, there is a Thread that i want to Terminate when Destructor of a Class called. Thread function is Using some functions of that class. I have done bit reading on Threading(still learning concepts etc) and about terminating a thread the way i want to use is AfxEndThread. it must be called within the thread that has to be terminated. or can it be called outside that thread also. or is there any way to terminate that thread from outside by some other thread.
<br />
pThread = AfxBeginThread(run,&nCount,THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);<br />
pThread->m_bAutoDelete=false;<br />
pThread->ResumeThread();
thats how i am initializing the Thread. Now what if i just delete pThread object will this terminate the thread.
**************************
bit more detail...
above code is placed in the constructor of same class .. now another class when makes object of this class thread should start working and when it delets the object thread must also be end. I am getting some assertion error while some where in terminating the thread. and don't know where
|
|
|
|
|
well the Error I am getting is
Debug Assertion Failed.
File: WinCore.cpp
Line: 1002
well is this problem of my thread. :s
|
|
|
|
|
Hallo, I had a simmilar problem and I solved the problem by using a shared bool var. if the var is set to true from outside the thread terminats its self. Try to use it.
Meinhard
|
|
|
|
|
thanks for your reply well my problem solved the problem was i was trying to access a class function when there was no class object .. i mean with empty pointer .. and there was one more problem that if i start the thread again before it ends up or the class object is destroyed this create problem because thread is still using the class and class object was deleted .. so i make 2 boolean when destructor call comes one goes to false and destructor goes in an empty loop and this false boolean tell thread ok end now. before thread ends it false the other one too .. to tell destructor ok i m finish now .. so destructor comes out of loop and object destroy. it is something like syncronization .. or what ever but problem is solved
|
|
|
|
|
|
I am working on an application, in which I need to transfer the data from excel file to the access. but I don't know how to read the header row in excel file, for help, with thanks.
qqwom
|
|
|
|
|
Hi, There
I have Problem with the right way that i can Sync. Files
in two folders. i.e. when a file added in one ,a copy will add in other folder.
Folders are in Two compuer Connected with
LAN,
Is there any Sevice, Program, utility, Source code For
This?
Thanks.
|
|
|
|
|
Search CP for synchronization-type projects. Google is also a good source.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
pls tell me an API from which i can get the space of each drive and the space left in it.
thanks
|
|
|
|
|
|
iReturnValue = ::GetDiskFreeSpaceEx(drives,
(PULARGE_INTEGER)&i64FreeBytesToCaller,
(PULARGE_INTEGER)&i64TotalBytes,
(PULARGE_INTEGER)&i64FreeBytes);
TCHAR *lptotalbyte=NULL;
TCHAR totalbyte[100];
lptotalbyte=_ui64toa(((PULARGE_INTEGER)&i64FreeBytesToCaller)->QuadPart,totalbyte,10);
i used this
in my system it is showing me wrong result
if i try in other sys it is showing 0
|
|
|
|
|
|