standard-library

Is there any builtin stable sort routine and swap function in .NET?

对着背影说爱祢 提交于 2019-12-01 22:09:41
问题 Is there any in-built stable sort routine in .NET? I know that C++ has an in-built sort routine under "algorithms" std::sort() . Likewise, do we have something to use along with C#? Also, is there any in-built swap function in .NET? 回答1: Using "C# stable sort" in Google revealed this SO post as top result: Is the sorting algorithm used by .NET's `Array.Sort()` method a stable algorithm? So the answer is: Enumerable.OrderBy is a stable sort function, not built into C#, but part of the .NET

Is there any builtin stable sort routine and swap function in .NET?

孤街醉人 提交于 2019-12-01 20:36:57
Is there any in-built stable sort routine in .NET? I know that C++ has an in-built sort routine under "algorithms" std::sort() . Likewise, do we have something to use along with C#? Also, is there any in-built swap function in .NET? Doc Brown Using "C# stable sort" in Google revealed this SO post as top result: Is the sorting algorithm used by .NET's `Array.Sort()` method a stable algorithm? So the answer is: Enumerable.OrderBy is a stable sort function, not built into C#, but part of the .NET framework libraries. Concerning "Swap": I don't know of any prebuilt generic swap function in the

Is the Python standard library really standard?

余生颓废 提交于 2019-12-01 18:05:33
Is the Python standard library standard in the sense that if Python is installed, then the standard library is installed too? The documentation reads For Unix-like operating systems Python is normally provided as a collection of packages, so it may be necessary to use the packaging tools provided with the operating system to obtain some or all of the optional components. The standard library index only lists as optional the "Optional Operating System Services", as far as I can tell. So, is everything else always available on a platform, if Python is installed? If not, what can be expected on

Regular Expression causing Stack Overflow

眉间皱痕 提交于 2019-12-01 16:18:49
问题 Further to my previous question: ECMAScript Regex for a multilined string, I have implemented the following loading procedure: void Load( const std::string& szFileName ) { static const std::regex regexObject( "=== ([^=]+) ===\\n((?:.|\\n)*)\\n=== END \\1 ===", std::regex_constants::ECMAScript | std::regex_constants::optimize ); static const std::regex regexData( "<([^>]+)>:([^<]*)\\n", std::regex_constants::ECMAScript | std::regex_constants::optimize ); std::ifstream inFile( szFileName );

Should I consider memmove() O(n) or O(1)?

倖福魔咒の 提交于 2019-12-01 16:08:52
this may be a silly question, but I want to calculate the complexity of one of my algorithms, and I am not sure what complexity to consider for the memmove() function. Can you please help / explain ? void * memmove ( void * destination, const void * source, size_t num ); So is the complexity O(num) or O(1). I suppose it's O(num), but I am not sure as I lack for now the understanding of what's going on under the hood. Since the running time of memmove increases in direct proportionality with the number of bytes it is required to move, it is O(n). What are you applying the memmove() operation to

Should I consider memmove() O(n) or O(1)?

北慕城南 提交于 2019-12-01 15:05:34
问题 this may be a silly question, but I want to calculate the complexity of one of my algorithms, and I am not sure what complexity to consider for the memmove() function. Can you please help / explain ? void * memmove ( void * destination, const void * source, size_t num ); So is the complexity O(num) or O(1). I suppose it's O(num), but I am not sure as I lack for now the understanding of what's going on under the hood. 回答1: Since the running time of memmove increases in direct proportionality

Why is the c++ standard library not working?

萝らか妹 提交于 2019-12-01 09:12:34
I've been trying to get my program that I downloaded from my schools server to run offline on my mac. I tried updating GCC by following tutorials and for some reason the tutorials didn't work even though I was using the commands given. Now when I compile.. I get an error saying that is not found.. I don't get it. I've updated Xcode.. followed tons of tutorials.. and I still can't get the thing to run! Why is it saying that random is not found, causing a fatal error? Thanks Error: DungeonLevel.h:6:10: fatal error: 'random' file not found "Since this is a coding site, I need to provide code

Member function pointer issue with standard library methods

淺唱寂寞╮ 提交于 2019-12-01 05:22:49
This question is spawned from Passing a member function pointer to an overloaded class method into a template function . You need not read that to understand this question. Probably both the questions will have the same answer. I am getting compiler error for below simple code . #include<set> template<typename Return, typename T> T ReceiveFuncPtr (Return (T::*Method)(const int&)) { T obj; // Found and declared an object of actual container class (obj.*Method)(1); // Some processing return obj; // Returned that container class object with RVO } int main () { ReceiveFuncPtr(&std::set<int>:

Can I seek a position beyond 2GB in C using the standard library?

拜拜、爱过 提交于 2019-12-01 05:14:30
I am making a program that reads disk images in C. I am trying to make something portable, so I do not want to use too many OS-specific libraries. I am aware there are many disk images that are very large files but I am unsure how to support these files. I have read up on fseek and it seems to use a long int which is not guaranteed to support values over 2 31 -1. fsetpos seems to support a larger value with fpos_t but an absolute position cannot be specified. I have also though about using several relative seeks with fseek but am unsure if this is portable. How can I support portably support

numeric_limits lowest and min member functions

雨燕双飞 提交于 2019-12-01 02:21:55
numeric_limits<T>::min(); numeric_limits<T>::lowest(); What is the different between the value returned by both functions? Paragraph 18.3.2.4 of the C++11 Standard specifies: static constexpr T min() noexcept ; 1 Minimum finite value. 2 For floating types with denormalization, returns the minimum positive normalized value. 3 Meaningful for all specializations [...] static constexpr T lowest() noexcept ; 6 A finite value x such that there is no other finite value y where y < x. 7 Meaningful for all specializations in which is_bounded != false. Footnote 197 then adds the relevant remark: lowest(