Monday, December 12, 2016

Digest for comp.lang.c++@googlegroups.com - 22 updates in 9 topics

Juha Nieminen <nospam@thanks.invalid>: Dec 12 01:16PM

> AFAIK quicksort will not work with linked lists; try merge sort instead.
 
"AFAIK"? Would it be too much to ask to not post guesses as answers?
 
Quicksort works with linked lists just fine. It's one of the standard
examples in language that use linked lists as its primary container
type (such as lisp and haskell).
 
It's only when you start using some fancier optimizations that it
becomes more difficult. For example choosing the pivot point as
the median of the first, last and middle elements. (This is still
possible with linked lists after the first partition, but requires
extra bookkeeping.)
Juha Nieminen <nospam@thanks.invalid>: Dec 12 01:18PM

> by rearranging the pointers.
> However if we swap both pointers and data of two nodes in list then
> we just break integrity of the list instead of sorting it.
 
He is talking about changing the prev/next pointers of the nodes to
make them change place in the list (in contrast to swapping the
values of the nodes.)
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 12 06:32PM

On 12/12/2016 13:16, Juha Nieminen wrote:
> the median of the first, last and middle elements. (This is still
> possible with linked lists after the first partition, but requires
> extra bookkeeping.)
 
If by "works" you mean "works slowly, O(n)".
 
/Flibble
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 12 06:34PM

On 12/12/2016 18:32, Mr Flibble wrote:
>> possible with linked lists after the first partition, but requires
>> extra bookkeeping.)
 
> If by "works" you mean "works slowly, O(n)".
 
By "O(n)" I actually meant "worse than O(n)*O(lg N)".
 
/Flibble
asetofsymbols@gmail.com: Dec 12 10:44AM -0800

O(n) is better than O(n*log(n)) in the few I know...
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 12 09:30PM

> O(n) is better than O(n*log(n)) in the few I know...
 
FFS. You didn't bother to read my correction reply then?
 
/Flibble
Jorgen Grahn <grahn+nntp@snipabacken.se>: Dec 12 07:08PM

On Sun, 2016-12-11, kushal bhattacharya wrote:
> hi,
 
> I am nearly new to c++,so i dont know how to build a configuration
> file for parsing json or xml.
 
I think you mean "write code to parse a configuration file written in
XML or JSON". There are free libraries for such tasks, for example
libxml2 and RapidJSON.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Popping mad <rainbow@colition.gov>: Dec 12 03:11PM

On Sun, 11 Dec 2016 10:35:23 -0500, Jerry Stuckle wrote:
 
> Maybe people keep discussing it because they are right and you are
> wrong.
> You obviously do not understand encapsulation.
 
 
 
your right.
Popping mad <rainbow@colition.gov>: Dec 12 03:13PM

On Sun, 11 Dec 2016 10:39:02 -0500, Jerry Stuckle wrote:
 
> He is correct. As was Sun, as was Stroustrup,
 
Stroustrup is barely understandable and Java is crap,
 
Its not that they are right. They were never right and the move away
from the paradigm has been extensive because it is too restrictive to
produce consistent APIS
 
 
And your off topic
 
 
Popping mad <rainbow@colition.gov>: Dec 12 03:14PM

On Sun, 11 Dec 2016 10:38:09 -0500, Jerry Stuckle wrote:
 
 
> Yes, OO is in part about creating easy to debug, maintainable and
> documentable code. But that can be done in any language.
 
> OO is mainly about producing code with fewer bugs.
 
 
 
Hahahaha
 
well that is a failure
 
OK we end this now. /dev/null
argue with the back of the hand
Jerry Stuckle <jstucklex@attglobal.net>: Dec 12 01:26PM -0500

On 12/12/2016 10:14 AM, Popping mad wrote:
 
> well that is a failure
 
> OK we end this now. /dev/null
> argue with the back of the hand
 
Not really. Good OO programmers typically have fewer bugs than good
non-OO programmers, for a number of reasons.
 
The biggest one is encapsulation and message passing isolates code,
which can then be tested for correct operation as a unit (and anything
that it depends on can be tested before this class).
 
It also allows bad data to be rejected at the time someone tries to set
it, not perhaps thousands of lines later when someone tries to use that
code. For instance, if you're looking at a Person object with an Age
member, you can test to ensure it is less than some value such as 120
years (the oldest person in the world is, I believe, around 116).
 
And inheritance and polymorphism allow for the reuse of existing code,
which supposedly has been tested and debugged already. This allows for
faster code development and fewer errors because people aren't
reinventing the wheel all the time.
 
Everyone makes mistakes, no matter what the language, and the number of
initial errors per LOC doesn't vary much with the language (although it
varies wildly with how good the design, if any, is). But OO allows more
bugs to be caught earlier in the development and testing cycle.
 
But if you just code "on the fly", with no testing other than "it
compiled", then no, you won't have fewer bugs in your code.
 
It all depends on the programmer, the design and the development/test
process.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Jerry Stuckle <jstucklex@attglobal.net>: Dec 12 01:28PM -0500

On 12/12/2016 10:13 AM, Popping mad wrote:
> On Sun, 11 Dec 2016 10:39:02 -0500, Jerry Stuckle wrote:
 
>> He is correct. As was Sun, as was Stroustrup,
 
> Stroustrup is barely understandable and Java is crap,
 
Stroustrup is quote understandable. And Java is a great language for
its use.
 
> Its not that they are right. They were never right and the move away
> from the paradigm has been extensive because it is too restrictive to
> produce consistent APIS
 
They were quite correct. And it is quite easy to produce consistent
APIs. You just need a good design and a programmer who isn't lazy.
 
 
> And your off topic
 
The use of encapsulation in a C++ program is quite on target for this
newsgroup.
 
 
>> and as are those Java
>> programmers who have tried to tell you the same.
 
Perhaps the experts and millions of other programmers know more than you
- and are more correct than you.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
ruben safir <ruben@mrbrklyn.com>: Dec 12 01:28PM -0500

Chris - check this video out, especially the later part
 
https://www.youtube.com/watch?v=XdP-Wjd1qSY
Juha Nieminen <nospam@thanks.invalid>: Dec 12 01:32PM

> typedef std::set< std::set<int>,
> [](const std::set<int>&x,const std::set<int>&y)
 
[](){} is not a type, it's an object. You can't use it as a type.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 12 04:15PM +0100

On 06.12.2016 14:03, Ralf Goertz wrote:
 
> is it possible to have a lambda expression as a template argument?
 
A lambda that doesn't capture converts willingly to pointer to function,
which could have been a template argument except for
 
* there is no such conversion for template arguments, and
 
* the standard enumerates what kinds of values can be template
arguments, as quoted by Stefan Ram else-thread, and lambdas are not in
that list.
 
 
> If not why not?
 
See above.
 
 
 
> error: lambda-expression in template-argument
 
> Background is that I'd rather have sets with fewer elements sorted
> before sets with more elements.
 
[code]
#include <set>
 
auto main()
-> int
{
using namespace std;
using Int_set = set<int>;
using Comparator_func = auto(*)(Int_set const&, Int_set const&) ->
bool;
using Set_of_sets = set<Int_set, Comparator_func>;
Set_of_sets blah{ [](Int_set const&x, Int_set const& y )
{
return x.size()==y.size() ? x<y : x.size()<y.size();
} };
}
[/code]
 
 
Cheers & hth.,
 
- Alf
Juha Nieminen <nospam@thanks.invalid>: Dec 12 01:37PM

> a loop and take it by the byte that the order is correct. It gets 00 00
> 00 and then 0d
 
> (which is 13)
 
The original answer given to you, ie. that you are interpreting the
bytes with the wrong endianess, was correct. Rather than understand
this, you decided to act like an ass instead.
Popping mad <rainbow@colition.gov>: Dec 12 03:17PM

On Mon, 12 Dec 2016 13:37:39 +0000, Juha Nieminen wrote:
 
> The original answer given to you, ie. that you are interpreting the
> bytes with the wrong endianess, was correct. Rather than understand
> this, you decided to act like an ass instead.
 
I understand this is correct, but I'm struggling with the nature of that
answer.
 
I know that was the answer prior to posting the question. I got an
explanation elsewhere.
Andrey Karpov <karpov2007@gmail.com>: Dec 12 12:52AM -0800

Since the release of the publicly available Linux-version of PVS-Studio, it was just a matter of time until we would recheck the Linux kernel. It is quite a challenge for any static code analyzer to check a project written by professionals from all around the world, used by people in various fields, which is regularly checked and tested by different tools. So, what errors did we manage to find in such conditions?
 
Article "Linux Kernel, tested by the Linux-version of PVS-Studio" - http://www.viva64.com/en/b/0460/
woodbrian77@gmail.com: Dec 11 08:48PM -0800

> try their command line option before their GUI as you hint at here.
 
> > You don't have to focus your work around it if you don't want to.
 
> Good point.
 
Does this look OK:
 
https://bitbucket.org/woodbrian/onwards
 
? The code that's out there is more recent than the version
that's on my website. I plan to use a BSD license, but
haven't gotten to that yet.
 

Brian
Ebenezer Enterprises - Making programming fun again.
http://webEbenezer.net
Christian Gollwitzer <auriocus@gmx.de>: Dec 12 09:51AM +0100

Hi Brian,
 
> Does this look OK:
 
> https://bitbucket.org/woodbrian/onwards
 
I've had a quick look at this site. I think you should work on the
description. Consider somebody not familiar with the CMW (or even with
serialization) to stumble upon this page. What will be the most
interesting for him?
 
I'd start with a one-sentence description of what this does, for
instance "The CMW is a serialization framework for the C++ programming
language. It offers..." then list a few highlights - what makes it
special/different, especially compared to strong competitors like boost?
Maybe put a very short code fragment on usage (of possible).
The licensing stuff should go last. You can put a single word in the
first line, like "the CMW is a .... under the BSD license".
 
I don't know if you can use Markdown on bitbucket, but if you can, this
will also greatly enhance the readability, and you can include
links/images/formatted code.
For instance, this is one of my projects. The folder list is
github-generated. Below you find my description of what the package does.
 
https://github.com/auriocus/VecTcl
 
 
HTH,
 
Christian
Melzzzzz <mel@zzzzz.com>: Dec 12 01:48AM +0100

On Sun, 11 Dec 2016 08:13:39 +0100
> int height_diff; // right subtree height - left
> subtree height
> };
 
How would you implement iterator without parent pointer? Why height
diff instead of just height as in AVL tree?
 
--
press any key to continue or any other to quit...
Jerry Stuckle <jstucklex@attglobal.net>: Dec 11 09:21PM -0500

On 12/11/2016 7:48 PM, Melzzzzz wrote:
>> };
 
> How would you implement iterator without parent pointer? Why height
> diff instead of just height as in AVL tree?
 
IMHO the best way would be to make the iterator recursive (which is
actually quite easy and doesn't take a lot of stack space).
Alternatively, you could follow down from the beginning of the tree
until you get to the current one, remembering the previous tree's
location. But that can be very time consuming if the tree has a large
number of nodes.
 
The easiest way is to have a pointer to the parent. It's a bit more
work to maintain the extra pointer, but not all that bad.
 
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: