Skip to content

Commit

Permalink
Put the code in src/ + update READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikkempa committed Jan 9, 2021
1 parent 7381718 commit f5f9d9b
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 63 deletions.
13 changes: 0 additions & 13 deletions no-parent-pointer/README

This file was deleted.

File renamed without changes.
10 changes: 10 additions & 0 deletions src/no-parent-pointer/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To test the tree type

$ make

and then

$ ./test

It checks the correctness of the code. Tests until valgrind (with the
--leak-check=full flag) report no leaks.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
/**
* @file zip_tree.hpp
* @section LICENCE
*
* Implementation of the Zip Tree without parent pointer, v0.1.0
* See: https://github.com/dominikkempa/zip-tree
*
* Copyright (C) 2018-2020
* Dominik Kempa <dominik.kempa (at) gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
**/

#ifndef __ZIP_TREE_HPP_INCLUDED
#define __ZIP_TREE_HPP_INCLUDED

Expand All @@ -7,7 +39,7 @@


//=============================================================================
// Node of a zip-tree.
// Node of a Zip Tree.
//=============================================================================
template<typename key_type, typename value_type>
class node {
Expand Down Expand Up @@ -47,7 +79,7 @@ class node {
};

//=============================================================================
// Simple implementation of zip-tree. It works with any key_type as
// Simple implementation of Zip Tree. It works with any key_type as
// long as objects of key_type can be compared using "<" operator.
//=============================================================================
template<typename key_type, typename value_type>
Expand Down
10 changes: 10 additions & 0 deletions src/with-parent-pointer/correctness-tests/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
To test the tree type

$ make

and then

$ ./test

It checks the correctness of the code. Tests until valgrind (with the
--leak-check=full flag) report no leaks.
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
/**
* @file zip_tree.hpp
* @section LICENCE
*
* Implementation of the Zip Tree with parent pointer, v0.1.0
* See: https://github.com/dominikkempa/zip-tree
*
* Copyright (C) 2018-2020
* Dominik Kempa <dominik.kempa (at) gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
**/

#ifndef __ZIP_TREE_HPP_INCLUDED
#define __ZIP_TREE_HPP_INCLUDED

Expand All @@ -7,7 +39,7 @@


//=============================================================================
// Node of a zip-tree.
// Node of a Zip Tree.
//=============================================================================
template<typename key_type, typename value_type>
class node {
Expand Down Expand Up @@ -50,7 +82,7 @@ class node {
};

//=============================================================================
// Simple implementation of zip-tree. It works with any key_type as
// Simple implementation of Zip Tree. It works with any key_type as
// long as objects of key_type can be compared using "<" operator.
//=============================================================================
template<typename key_type, typename value_type>
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions src/with-parent-pointer/speed-tests/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
To run performance tests type

$ make

and then

$ ./test

The results for this preliminary implementation of Zip Trees are
already very interesting. On my computer the insertion into Zip Trees
(in random order) is only about 50% slower than for Red-Black
trees. Interestingly, insertion in sorted order is usually slightly
faster for Zip Trees.

As for searching and deleting, on my machine the Zip Trees are only
about 15-25% slower than Red-Black trees.

Perhaps further engineering of Zip Trees can yield some improvements,
e.g., eliminating recursion in the insertion. I studied a bit the
Reb-Black tree implementation in the C++ standard library and found
that most functions are re-written into iterative versions, e.g., see
the _Rb_tree_insert_and_rebalance function in

github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/src/c++98/tree.cc
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
/**
* @file zip_tree.hpp
* @section LICENCE
*
* Implementation of the Zip Tree with parent pointer, v0.1.0
* See: https://github.com/dominikkempa/zip-tree
*
* Copyright (C) 2018-2020
* Dominik Kempa <dominik.kempa (at) gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
**/

#ifndef __ZIP_TREE_HPP_INCLUDED
#define __ZIP_TREE_HPP_INCLUDED

Expand All @@ -7,7 +39,7 @@


//=============================================================================
// Node of a zip-tree.
// Node of a Zip Tree.
//=============================================================================
template<typename key_type, typename value_type>
class node {
Expand Down Expand Up @@ -50,7 +82,7 @@ class node {
};

//=============================================================================
// Simple implementation of zip-tree. It works with any key_type as
// Simple implementation of Zip Tree. It works with any key_type as
// long as objects of key_type can be compared using "<" operator.
//=============================================================================
template<typename key_type, typename value_type>
Expand Down
13 changes: 0 additions & 13 deletions with-parent-pointer/correctness-tests/README

This file was deleted.

31 changes: 0 additions & 31 deletions with-parent-pointer/speed-tests/README

This file was deleted.

0 comments on commit f5f9d9b

Please sign in to comment.