- About my Good random number generators and scalability.. - 2 Updates
- Encouraging remarks - 1 Update
- [Modération JNTP] Annulation de <pr2830$g9c$4@dont-email.me> - 1 Update
- Clipboard Interfacing - 6 Updates
- Help with memory management question using C++11 - 7 Updates
- Concatenating strings efficiently - 1 Update
- Fastest Sorting Algorithm. Ever! - 1 Update
Horizon68 <horizon@horizon.com>: Oct 27 10:42AM -0700 Hello, About my Good random number generators and scalability.. I think my mersenne and splitmix64 random generators can work with multiple threads and can be "scalable", look at at ThreadedRandomizedSeed() method to obtain a random seed: == function TMersenne.ThreadedRandomizedSeed():longword; var a:double; begin if bool1=false then begin bool1:=true; a:=sin(GetCurrentThreadId)*high(longword); if a < 0 then a:=-a; if not assigned(mersenne1) then mersenne1:=TMersenne.create; mersenne1.initialize(round(a)); result:=mersenne1.urand; end else result:=mersenne1.urand; end; == You can create a mersenne or splitmix64 object for every thread and initialize in each thread with ThreadedRandomizedSeed(), and after than get your random number in each thread, i think this way is "scalable". My Good random number generators for Delphi and FreePascal was updated to version 1.01, you can port them to C++.. Look at them they are powerful. Author: Amine Moulay Ramdane that has enhanced both random number generators. Description: This is an enhanced versions of both Mersenne Twister that is a good random number generator and Splitmix64 that is a fast random number generator, both have passed the BigCrush tests. Look into defines.inc file, there is many options: {$DEFINE CPU32} and {$DEFINE Windows32} for 32 bit systems {$DEFINE CPU64} and {$DEFINE Windows64} for 64 bit systems Look at test.pas demo inside the zip file... You can download it from: https://sites.google.com/site/scalable68/good-random-number-generators Language: FPC Pascal v2.2.0+ / Delphi 5+: http://www.freepascal.org/ Operating Systems: Win , Linux and Mac (x86). Required FPC switches: -O3 -Sd -Sd for delphi mode.... Required Delphi switches: -$O+ Thank you, Amine Moulay Ramdane. |
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 27 03:09PM -0700 On 10/27/2018 10:42 AM, Horizon68 wrote: > begin > bool1:=true; > a:=sin(GetCurrentThreadId)*high(longword); Partitioning wrt angle as thread id... [...] |
Paul <pepstein5@gmail.com>: Oct 27 01:16PM -0700 On Tuesday, October 2, 2018 at 7:56:08 PM UTC+1, David Brown wrote: > Marvellous. Keep asking questions, and keep learning. That's what this > newsgroup is for (despite appearances sometimes). > Once you have had a try, post your code if you are not sure about it. Thanks for your encouragement. I am actually looking for a C++ tutor, by the way, for online sessions via something like Google hangout. If anyone is interested, please reply to author and we can discuss rates and availability. I drafted a new topic with this tutoring request, but I thought I might get in trouble on OT grounds. I know there are standard websites for tutoring but I think the advice here is far more expert than what I would get from a tutoring website. Thanks, Paul |
Elephant Man <conanospamic@gmail.com>: Oct 27 07:19PM Article d'annulation émis par un modérateur JNTP via Nemo. |
tomusatov@gmail.com: Oct 27 06:21AM -0700 I am wondering if C++ would be the best language to write a program allowing: 1. Highlight some text 2. Ctl+HOTKEY1 stores the string of text somewhere as COPIEDTEXT1 3. Highlight another string of text 4. Ctl+HOTKEY1 stores another string of text somewhere as COPIEDTEXT2 THEN 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 Can someone point me in the right direction? Thanks, Musatov |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Oct 27 03:32PM +0200 > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > Can someone point me in the right direction? You /can/ do it in C++. Depending on the system you want to do this for, some other language will probably be less work. Right direction pointer: when Microsoft replaced the original Windows clipboard viewer with one supporting multiple clips, like you sketch, that marked the end of having a standard clipboard viewer in Windows. The clipboard relies on simplicity for it to be useful. Adding complexity and hidden modes is therefore not a good direction. Cheers & hth., - Alf |
Luuk <luuk@invalid.lan>: Oct 27 03:38PM +0200 > Can someone point me in the right direction? > Thanks, > Musatov In Windows 10 (from build 1809) you can view your copies with Windows+V. CTRL+C copies (and adds to the list) CTRL+V pastes Windows+V (shows the list) Now one has to wait till 1809 get released... |
Sam <sam@email-scan.com>: Oct 27 10:02AM -0400 > 5. Ctl+HOTKEY2 pastes COPIEDTEXT1 > 6. Ctl+HOTKEY2 pastes COPIEDTEXT2 > Can someone point me in the right direction? The right direction for you would be some general books on computer programming, where you will learn that in the several thousand of terse, single-spaced pages that make up the current C++ standard, there is no mention whatsoever about "highlighting" text, in some mysterious fashion, or equally-mysterious "hotkeys", that do wondrous things. This is purely a function of your operating system, and the exact task for implementing these kinds of things depend entirely on the operating system being used. Since you don't even realize that this is an operating system-specific question, and you didn't specify which OS you're using, I think it would be rather difficult, if not impossible, for you to implement the task at hand right now; but maybe several years down the road. It just so happens that last week I finished implementing copy/cut/paste support in my X toolkit library (shameless plug: https://www.libcxx.org/w/copycutpastemenu.html). I don't remember exactly when I started it, but I've been working on this library for the last eight years, and coding C++ for …much longer than that. Just to give you a rough idea how complicated C++-related things are, in the real world. The only other thing I can tell you with some level of confidence is that, whatever operating system you're using, it's unlikely that you will be able to modify its default copy/cut/paste behavior in the manner you desire. All traditional OSrd implement copy/cut/paste internally, behind the scenes, and their exact mechanics are not exposed to applications. The mouse pointer operations and/or the keyboard shortcuts for copy/cut/pasting text get processed entirely by the operating system, or the GUI library being used on your operating system. The application does not even realize that this is happening. The OS/GUI library handles the mechanics of this process entirely on its own. All that the application does is put up text input fields, where text gets typed in when that text input field has keyboard focus, and the OS or the GUI library handles copy/cut/paste operations on its own. All the application cares about is text that mysterious appears in its aforementioned text input fields, and how it got there, it doesn't really care. Some OSes might offer third-party add-on tools that enhance the existing copy/cut/paste behavior. Those tools typically use highly OS-specific internal functions to modify its copy/cut/paste behavior. |
Manfred <noname@add.invalid>: Oct 27 06:41PM +0200 On 10/27/2018 4:02 PM, Sam wrote: > question, and you didn't specify which OS you're using, I think it would > be rather difficult, if not impossible, for you to implement the task at > hand right now; but maybe several years down the road. The above sounds excessively hard on the poor OP. > last eight years, and coding C++ for …much longer than that. Just to > give you a rough idea how complicated C++-related things are, in the > real world. It is true that C++ is a complex language, but in this case (copy/paste of strings) the complexity is not about usage of the language, instead it is mainly about how to interface with the OS - or better, how to interface with whatever GUI manager is offered by the target platform. Even this part, however, is not complex in the sense that it be rocket science. Most of the work would be finding and digging through the documentation of the system API, the patterns used throughout it, and such API's are usually very large. > for copy/cut/pasting text get processed entirely by the operating > system, or the GUI library being used on your operating system. The > application does not even realize that this is happening. It is true that it would be impossible or next to impossible to modify the system clipboard behavior. It is instead possible to override the relevant commands and implement your own clipboard scheme. Obviously this would only work within your own applications. Again, this is not a C++ problem, it is GUI software development instead. The OS/GUI |
tomusatov@gmail.com: Oct 27 11:54AM -0700 On Saturday, October 27, 2018 at 8:38:46 AM UTC-5, Luuk wrote: > CTRL+V pastes > Windows+V (shows the list) > Now one has to wait till 1809 get released... Bout time. Amen! |
Paul <pepstein5@gmail.com>: Oct 27 02:19AM -0700 Below, I will post a question that I would like some help with (if possible). The best type of help would be something like "Think about using..." rather than just giving the answer. I would like to avoid using post-C++11 features if possible. People sometimes get (rightly) homework-suspicious when they see posts like these. This question is for self-study purposes only. I am not a student, and am not enrolled in any course. It is also not part of any external evaluation process or interview process. The source of the original question is https://www.testdome.com/questions/cpp/multiple-choice-test/9808?visibility=1&skillId=7 I have tried the very basic solution of using delete[] in the destructor without using smart pointers. That is not the intended solution. I tried using unique pointers with release(). This compiled but was also not the intended solution. reset() wasn't what they wanted either. Many thanks for your help, Paul // CODE BELOW /*Multiple choice test has several multiple choice questions. Each question can have only one correct answer. Additionally, timed multiple choice test can specify the time allowed for solving each question in the test. The code below satisfies this specification, but the customer complained that the memory usage of the program constantly increases. Fix this problem.*/ #include <iostream> #include <string> class MultipleChoiceTest { public: MultipleChoiceTest(int questionsCount) { this->questionsCount = questionsCount; answers = new int[questionsCount]; for (int i = 0; i < questionsCount; i++) { answers[i] = -1; } } void setAnswer(int questionIndex, int answer) { answers[questionIndex] = answer; } int getAnswer(int questionIndex) const { return answers[questionIndex]; } protected: int questionsCount; private: int* answers; }; class TimedMultipleChoiceTest : public MultipleChoiceTest { public: TimedMultipleChoiceTest(int questionsCount) : MultipleChoiceTest(questionsCount) { times = new int[questionsCount]; for (int i = 0; i < questionsCount; i++) { times[i] = 0; } } void setTime(int questionIndex, int time) { times[questionIndex] = time; } int getTime(int questionIndex) const { return times[questionIndex]; } private: int* times; }; #ifndef RunTests void executeTest() { MultipleChoiceTest test(5); for (int i = 0; i < 5; i++) { test.setAnswer(i, i); } for (int i = 0; i < 5; i++) { std::cout << "Question " << i + 1 << ", correct answer: " << test.getAnswer(i) << "\n"; } } int main() { for (int i = 0; i < 3; i++) { std::cout << "Test: " << i + 1 << "\n"; executeTest(); } }
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment