|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Is it possible to access element by index (like in array or vector), when using multiset?
|
|
|
|
|
no
but you can walk through the collection with an iterator.
|
|
|
|
|
I found, that it is possible only to iterate in this way:
multiset<double> s;
multiset<double>::iterator it;
it = s.begin();
for (int i = 0; i < s.size(); ++i)
it++;
I tried to do the following:
it += k;
But that doesn't work. Is there any oppotunity to "jump" to the position?
|
|
|
|
|
as you've already started discussion on same topic, please continue your discussion in previous thread.
multiset is a node based container. It's not implemented using contigeous memory allocation. Please check the documentation of multiset.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi all,
could somebody please suggest an API which can split wave files into small chunks of userspecified timespans
Eg: a.wav -60 seconds.
after splitting we should get
a1.wav -20 sec
a2.wav -20 sec
a3.wav -20 sec
respectively
any help could be appreciated.
thanks.
|
|
|
|
|
The header of the wavefile contains the samplefrequency (and the number of bits of one sample, mono, stereo). Next the samplepoints follow. From the data in the header you can figure out which part of the samples you need... (i must somewhere have a description of the wavefile format...)
Rozis
|
|
|
|
|
Hi,
I am new to development world...
I am actually converting my application to unicode supporting one.. i have a problem like this..
Requirement :
I should view both ASCII encoded files and UNICODE encoded files..
Scenario:
The following code snippet was used to convert to wide characters after reading content from file.. this code works fine with ASCII encoded files but doesnt work fine if i try to view unicode encoded file. the prob. lies in the last line...(Buffer->Txt = Buf) since MultiByteToWideChar(CP_ACP, 0,(LPCSTR)Buffer->Txt, -1, (LPWSTR)Buf, nBuflength); returns some junk value to Buf....
...
My Doubt is this:
I Observed keenly that whenever i try to upload unicode fille, nBuflength will be 4 and for ascii it will be 529273(not sure abt this value).. i have used an if statement here to make it work...
is it a hard-coded one??
Code Snippet:
Buffer is a structure object and Txt is a WCHAR* type.
wchar_t *Buf = NULL ;
int nBuflength = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)Buffer->Txt, -1, (LPWSTR)Buf, 0);
Buf = new wchar_t[nBuflength];
if( (nnBuflength/2) != sizeof(WCHAR))
{
MultiByteToWideChar(CP_ACP, 0,(LPCSTR)Buffer->Txt, -1, (LPWSTR)Buf, nBufLen);
Buffer->Txt = Buf;
}
else
------------------
Can we do in any other way to achieve my objective or is this a final one??
plss help me...
Thanks,
Rakesh.
Rakesh S
|
|
|
|
|
You need to (somehow) detect whether the file is multi-byte (e.g. ASCII) or Unicode before attempting to translate to Unicode. IsTextUnicode [^] can help you do that, even if Michael Kaplan doesn't like it[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
What does "Changing language" mean?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
In ControlPanel->Regional and Language Options->Advanced Tab-> there is an option "Language for non-Unicode programs", I want to change it programatically, is there any API for that???
|
|
|
|
|
I'm not sure, but see if _tsetlocale()[^] helps (I do not have VS on this machine, so I cannot test it either).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Thank you Rajesh... this helps me I guess, will test it
|
|
|
|
|
What you are describing is a System Locale and it cannot be changed programatically.
|
|
|
|
|
Hello, I have to add data to a vector in sorted order.
For example:
3,7,3,4
must be:
1)3
2)3,7
3)3,3,7
4)3,3,4,7
What is the most quick way to do this? Or maybe other data stuctures like Map would be better for this task?
|
|
|
|
|
You may use a multiset [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
alikalik wrote: Or maybe other data stuctures like Map would be better for this task?
std::set[^] is a sorted associative container.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hm... But is it possible to access the element at the specified index in multiset?
|
|
|
|
|
Depends on the usage patterns. If the number of lookups is significantly higher than the number of inserts, then I'd just use a sorted vector (as my experiences indicate that a binary search on a sorted vector is significantly faster than use of STL's associative containers in C++). If inserts are more significant than that, use a std::multiset as suggested elsewhere.
If using a sorted vector, it helps to delay the sort operation until required, using something like below, rather than blindly sorting on every insert.
template<class Type>
class SortedVector
{
public:
SortedVector() sorted_(true) {}
void insert(Type const& value)
{
sorted_ = false;
data_.push_back(value);
}
typename std::vector<Type>::const_iterator find(Type const& value) const
{
if (!sorted_)
{
std::sort(data_.begin(), data_.end());
sorted_ = true;
}
std::vector<Type>::const_iterator found =
std::lower_bound(data_.begin(), data_.end(), value);
return (*found == value)?found:data_.end();
}
private:
mutable bool sorted_;
mutable std::vector<Type> data_;
};
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
im trying to override create function for modelessDialog Box.. as follows..
CTestDlgDlg (application name)
BOOL CTestDlgDlg::Create(UINT nID, CWnd* pParent)
{
CDialogTemplate dlt;
int nResult;
// load dialog template
if (!dlt.Load(MAKEINTRESOURCE(CTestDlgDlg::IDD))) return FALSE;
// get pointer to the modified dialog template
LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
LPDLGTEMPLATE pDlgTemplate = (LPDLGTEMPLATE)pdata;
//pDlgTemplate->style |= DS_SETFONT;
// set your own font, for example "Arial", 10 pts.
dlt.SetFont(L"Arial", 12);
// let MFC know that you are using your own template
m_lpszTemplateName = NULL;
//InitModalIndirect(pdata);
// display dialog box
//nResult = CDialog::DoModal();
// unlock memory object
// CDialog::Create(nID,pParent);
CDialog::CreateDlgIndirect(pDlgTemplate, pParent, AfxGetInstanceHandle());
GlobalUnlock(dlt.m_hTemplate);
}
But it behaves same as modal Dialog box Instead of modeless ..
Please try to help..
|
|
|
|
|
Is there a CDialog::CreateDlgIndirect?
There sure is a CDialog::CreateDialogIndirect.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
CDialog::CreateDlgIndirect is present it"s a private function in dlgcore.cpp ..it"s a CWND class member function....
|
|
|
|
|
But it's not virtual, so if CreateDlgIndirect is called using an instance pointer typed as CDialog (which is highly likely, as CDialog is the only class with visibility of that method), it'll always call the CDialog version of the method.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
This is from MSDN
"Quote"
FIX: The CDialog::Create() function returns an incorrect value when a dialog box is created in Visual C++
View products that this article applies to.
This article was previously published under Q193099
"Unquote"
Sample:
// Create a modeless dialog box. In this example, m_pModeless is a
// member variable of type CModeless where CModeless is a CDialog-
// derived class. IDD_MODELESS is the ID number of a dialog-box template
// resource.
m_pModeless = new CModeless;
if (m_pModeless->Create(IDD_MODELESS, this) && ::IsWindow(m_pModeless->m_hWnd))
{
// ... succeeded in dialog-box creation.
}
else
{
// ... failed in dialog-box creation.
}
Once again from MSDN.
For me personally. I have always created the dialog box first, tested it as a modal dialog and then made it modeless by creating it as follows:
LogonDlg* pDlg = new LogonDlg;
// create it if necessary
LogonDlg * pApp = (LogonDlg*)AfxGetApp()->m_pMainWnd;
if (pApp->m_hWnd == NULL && !pApp->Create(LogonDlg::IDD))
{
CTraceLog::TraceMsg( "InitInstance failed to create LogonDlg" );
return FALSE;
}
pApp->SetVisibility( SW_HIDE );
|
|
|
|