tag:blogger.com,1999:blog-6314876008291942531.post3673210141307118121..comments2024-01-14T00:36:43.430-08:00Comments on Antonio Gulli's coding playground: Generic Skip list (skiplist)Unknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-6314876008291942531.post-24448386901575222422011-01-20T05:30:01.259-08:002011-01-20T05:30:01.259-08:00I believe you have a bug in your search__ function...I believe you have a bug in your search__ function:<br /><br />if ((x == 0)) ||<br /> (key < x->val_))<br /><br />Shouldn't this read:<br /><br />if ((x == 0)) ||<br /> (key < x->key_))<br /><br />?flohttps://www.blogger.com/profile/00298551866231251731noreply@blogger.comtag:blogger.com,1999:blog-6314876008291942531.post-27700935896465972242009-06-18T05:50:36.054-07:002009-06-18T05:50:36.054-07:00@anonymous:
of course it does for && and ...@anonymous:<br /><br />of course it does for && and ||: it is called shortcut evaluation, and test for null OR dereference is idiomatic both in C and C++.gpdhttps://www.blogger.com/profile/05203003070079644473noreply@blogger.comtag:blogger.com,1999:blog-6314876008291942531.post-69299415491856158102009-05-30T04:11:32.075-07:002009-05-30T04:11:32.075-07:00if ((tk == 0) || // null?
( key ...if ((tk == 0) || // null?<br /> ( key < tk->key_)) // search key < next level link's key<br /><br />Is not correct. C++ does not guarantee left to right evaluation and so this may result in a segmentation fault depending on the compiler.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6314876008291942531.post-43039545761520241232009-03-23T04:14:00.000-07:002009-03-23T04:14:00.000-07:00more precisely: "are an interesting"more precisely: "are an interesting"codingplaygroundhttps://www.blogger.com/profile/08478993186814330588noreply@blogger.comtag:blogger.com,1999:blog-6314876008291942531.post-83496025081035251532009-03-23T01:21:00.000-07:002009-03-23T01:21:00.000-07:00The right grammar should be that "skip lists are a...The right grammar should be that "skip lists are a ..."Anonymousnoreply@blogger.com