mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
nic_router: Avl_tree wrapper with destroy_each
AVL tree wrapper with method to destruct and deallocate each item of the tree. Ref #2670
This commit is contained in:
parent
44dd55a268
commit
5926261e08
38
repos/os/src/server/nic_router/avl_tree.h
Normal file
38
repos/os/src/server/nic_router/avl_tree.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* \brief Genode AVL tree with additional functions needed by NIC router
|
||||
* \author Martin Stein
|
||||
* \date 2016-08-19
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _AVL_TREE_H_
|
||||
#define _AVL_TREE_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/avl_tree.h>
|
||||
#include <base/allocator.h>
|
||||
|
||||
namespace Net { template <typename> class Avl_tree; }
|
||||
|
||||
|
||||
template <typename ITEM_T>
|
||||
struct Net::Avl_tree : Genode::Avl_tree<ITEM_T>
|
||||
{
|
||||
using Base = Genode::Avl_tree<ITEM_T>;
|
||||
|
||||
void destroy_each(Genode::Deallocator &dealloc)
|
||||
{
|
||||
while (ITEM_T *item = Base::first()) {
|
||||
Base::remove(item);
|
||||
destroy(dealloc, item);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _AVL_TREE_H_*/
|
Loading…
x
Reference in New Issue
Block a user