|
Member 4399131 wrote: Well I think I beat the standard runtime library!!!
Well done!
However, since I read your answer to Stuart I understand you've implemented this using inline assembler. It would be really nice to write it in C/C++ in such way that the compiler would generate the same tight code. That would make it more portable.
The algorithm used is quite interesting...
I guess using a bit table will result in a lot of calculations in order to get the correct bit if not using inline assembler. If size of the table is not an issue I would try using chars or ints instead because then indirect addressing can be used, which I assume will faster.
For the sake of my own curiosity (and amusement) I'll try that and compare it.
I'm not aware of any statement in C that would make use of assembly bit manipulation instructions with bit numbers higher than e.g. 31 on a 32-bit system. So I guess inline assembler is the only choice.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: It would be really nice to write it in C/C++ in such way that the compiler would generate the same tight code. That would make it more portable.
YES! Not only more portable, if the code is in C/C++ the compiler will have a far better chance to build-in the entire inline function!
All of my functions are declared inline, but since I use inline assembly inside them, I make explicit use of specific registers, thus not allowing the compiler to use the currently free ones! In effect the compiler couldn't build-in the function, but compiles it as a normal procedure and CALLs it with all stack operations necessary. Fortunately the runtime library is just the same story! It's full of CALLs and PUSH-POPs , for instance: before CString::FindOneOf gets ready to call of strspn it passes through whole bunch of them!
And I already had some issues using inline assembly, for example: when I installed a new version of NOD32 and scaned the PC, it detected my test application as unknown virus, obviously it somehow detected the unusual assembly code and alarmed. NOD32 is actually known assembly code analyser, that's probably because the inline assembly is mostly used by virus writers these days. I used the option to send them the EXE for analysis to see that it's not bad at all!
I considered writing my algorithms in C/C++ too great effort (at least for now). A lot of other functions await me to implement them after all. And I'm willing to give them just as much attention as I gave to FindOneOf if necessary. Let me see the entire conception working and then I'll try the "siplusplusing" (I just got this term )
Roger Stoltz wrote: I'm not aware of any statement in C that would make use of assembly bit manipulation instructions with bit numbers higher than e.g. 31 on a 32-bit system.
Why don't you try to write some yourself?
inline void operator [] (void* pBitTable, int index)
{
__asm
{
mov EAX, index
bts pBitTable, EAX
}
};
inline bool operator [] (void* pBitTable, int index)
{
__asm
{
mov EAX, index
bt pBitTable, EAX
jb True
xor EAX, EAX
jmp Skip
True: mov EAX, 1
Skip:
}
};
Well these hardly will give better rsults than pure assembly code, but who knows what miracles the compiler/optimizer are capable of! I think there is a GOOD chance for the compiler to build these in 'cause only EAX is named directly and you know it's reserved for the return value and the compiler keeps it free before any call
(the code above is just to give you the idea I haven't eaven tested it! But I do think it's a good idea and I'm pretty sure it'll work fine)
modified on Thursday, June 25, 2009 10:44 AM
|
|
|
|
|
Hi All,
I am trying to post data to server and get the response for the same through xmlhttp request.but i am getting status code 415 in response below is my code snippet:
hr=pIXMLHTTPRequest->
open("POST", "http://www.lowcostholidays.com/webservices/search.asmx",false);
SUCCEEDED(hr) ? 0 : throw hr;
int ssttr11 = ssttr.GetLength();
_bstr_t mylong = (_variant_t)(long)ssttr11;
pIXMLHTTPRequest->setRequestHeader("Content-type", "text/html;charset=utf-8");
pIXMLHTTPRequest->setRequestHeader("Content-length",mylong);
hr=pIXMLHTTPRequest->send(SomeURL)
SUCCEEDED(hr) ? 0 : throw hr;
int aa = pIXMLHTTPRequest->readyState;
int bb = pIXMLHTTPRequest->status;
BSTR stext,rtext;
pIXMLHTTPRequest->get_statusText(&stext);
hr = pIXMLHTTPRequest->get_responseText(&rtext)
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
I guess the server told you "415" => Unsupported media type
comment this out, it isnt needed
pIXMLHTTPRequest->setRequestHeader("Content-length",mylong);
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hallo,
i need to display a timer in the statusbar to show how much time the application need to do
a task, if the application is Idle the time shown in the statusbar is 00:00:00(i alreday have this done)
but if the applicatioon is busy the timer should display the time has benn requierd.
How can i do this and in which files of my SDI-Application please.
|
|
|
|
|
Start a timer (have it fire every 1000 ms) when your application starts the task (Should be done on a separate thread if it is lengthy. Because timer messages won't pile up). Use thread synchronization to know when the thread exits and kill your timer there. The timer event handler must have the code to display the time taken.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
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?
|
|
|
|