/* * \brief Slightly improved list * \author Christian Helmuth * \date 2014-09-25 */ /* * Copyright (C) 2014 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. */ #ifndef _LX_EMUL__IMPL__INTERNAL__LIST_H_ #define _LX_EMUL__IMPL__INTERNAL__LIST_H_ #include namespace Lx { template class List; template class List_element; } template class Lx::List : private Genode::List { private: typedef Genode::List Base; public: using Base::Element; void append(LT const *le) { LT *at = nullptr; for (LT *l = first(); l; l = l->next()) at = l; Base::insert(le, at); } void prepend(LT const *le) { Base::insert(le); } void insert_before(LT const *le, LT const *at) { if (at == first()) { prepend(le); return; } else if (!at) { append(le); return; } for (LT *l = first(); l; l = l->next()) if (l->next() == at) at = l; Base::insert(le, at); } /**************************** ** Genode::List interface ** ****************************/ LT *first() { return Base::first(); } LT const *first() const { return Base::first(); } void insert(LT const *le, LT const *at = 0) { Base::insert(le, at); } void remove(LT const *le) { Base::remove(le); } }; template class Lx::List_element : public Lx::List >::Element { private: T *_object; public: List_element(T *object) : _object(object) { } T *object() const { return _object; } }; #endif /* _LX_EMUL__IMPL__INTERNAL__LIST_H_ */