From 0f7252ab76ad5f084569bbb827efd3ee2b18e688 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 2 Sep 2019 12:49:26 -0400 Subject: [PATCH] ramfs: Remove unused SLList.h. --- .../kernel/file_systems/ramfs/SLList.h | 265 ------------------ 1 file changed, 265 deletions(-) delete mode 100644 src/add-ons/kernel/file_systems/ramfs/SLList.h diff --git a/src/add-ons/kernel/file_systems/ramfs/SLList.h b/src/add-ons/kernel/file_systems/ramfs/SLList.h deleted file mode 100644 index 97e1a43092..0000000000 --- a/src/add-ons/kernel/file_systems/ramfs/SLList.h +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 2003, Ingo Weinhold, ingo_weinhold@gmx.de. - * All rights reserved. Distributed under the terms of the MIT license. - */ -#ifndef SL_LIST_H -#define SL_LIST_H - -#include - -// SLListStandardNode -template -struct SLListStandardNode { - SLListStandardNode(const Value &a) - : value(a), - next(NULL) - { - } - - Value value; - SLListStandardNode *next; -}; - -// SLListStandardNodeAllocator -template -class SLListStandardNodeAllocator -{ -public: - inline Node *Allocate(const Value &a) const - { - return new(nothrow) SLListStandardNode(a); - } - - inline void Free(Node *node) const - { - delete node; - } -}; - -// SLListValueNodeAllocator -template -class SLListValueNodeAllocator -{ -public: - inline Node *Allocate(const Value &a) const - { - return a; - } - - inline void Free(Node *node) const - { - } -}; - -// SLListStandardGetValue -template -class SLListStandardGetValue -{ -public: - inline Value &operator()(Node *node) const - { - return node->value; - } -}; - -// SLListValueNodeGetValue -template -class SLListValueNodeGetValue -{ -public: - inline Value &operator()(Node *node) const - { - return *node; - } -}; - -// for convenience -#define SL_LIST_TEMPLATE_LIST template -#define SL_LIST_CLASS_NAME SLList - -// SLList -template, - typename NodeAllocator = SLListStandardNodeAllocator, - typename GetValue = SLListStandardGetValue > -class SLList { -public: - class Iterator; - -public: - SLList(); - SLList(const NodeAllocator &nodeAllocator, const GetValue &getValue); - ~SLList(); - - bool Insert(const Value &value, Iterator *iterator = NULL); - bool Remove(const Value &value); - void Remove(Iterator &iterator); - void RemoveAll(); - - bool Find(const Value &value, Iterator *iterator = NULL) const; - void GetIterator(Iterator *iterator) const; - -private: - friend class Iterator; - - Node *fHead; - NodeAllocator fNodeAllocator; - GetValue fGetValue; -}; - -// Iterator -SL_LIST_TEMPLATE_LIST -class SL_LIST_CLASS_NAME::Iterator { -public: - Iterator() : fList(NULL), fCurrent(NULL) {} - ~Iterator() {} - - inline Value *GetCurrent() - { - return (fList && fCurrent ? &fList->fGetValue(fCurrent) : NULL); - } - - inline Value *GetNext() - { - if (fCurrent) - fCurrent = fCurrent->next; - return GetCurrent(); - } - - inline void Remove() - { - if (fList) - fList->Remove(*this); - } - -private: - friend class SL_LIST_CLASS_NAME; - - inline void _SetTo(SL_LIST_CLASS_NAME *list, Node *previous, Node *node) - { - fList = list; - fPrevious = previous; - fCurrent = node; - } - - inline SL_LIST_CLASS_NAME *_GetList() const { return fList; } - inline Node *_GetPreviousNode() const { return fPrevious; } - inline Node *_GetCurrentNode() const { return fCurrent; } - -private: - SL_LIST_CLASS_NAME *fList; - Node *fPrevious; - Node *fCurrent; -}; - -// constructor -SL_LIST_TEMPLATE_LIST -SL_LIST_CLASS_NAME::SLList() - : fHead(NULL)/*, - fNodeAllocator(), - fGetValue()*/ -{ -} - -// constructor -SL_LIST_TEMPLATE_LIST -SL_LIST_CLASS_NAME::SLList(const NodeAllocator &nodeAllocator, - const GetValue &getValue) - : fHead(NULL), - fNodeAllocator(nodeAllocator), - fGetValue(getValue) -{ -} - -// destructor -SL_LIST_TEMPLATE_LIST -SL_LIST_CLASS_NAME::~SLList() -{ - RemoveAll(); -} - -// Insert -SL_LIST_TEMPLATE_LIST -bool -SL_LIST_CLASS_NAME::Insert(const Value &value, Iterator *iterator) -{ - Node *node = fNodeAllocator.Allocate(value); - if (node) { - node->next = fHead; - fHead = node; - if (iterator) - iterator->_SetTo(this, NULL, node); - } - return node; -} - -// Remove -SL_LIST_TEMPLATE_LIST -bool -SL_LIST_CLASS_NAME::Remove(const Value &value) -{ - Iterator iterator; - bool result = Find(value, &iterator); - if (result) - iterator.Remove(); - return result; -} - -// Remove -SL_LIST_TEMPLATE_LIST -void -SL_LIST_CLASS_NAME::Remove(Iterator &iterator) -{ - Node *node = iterator._GetCurrentNode(); - if (iterator._GetList() == this && node) { - Node *previous = iterator._GetPreviousNode(); - iterator._SetTo(this, previous, node->next); - if (previous) - previous->next = node->next; - else - fHead = node->next; - fNodeAllocator.Free(node); - } -} - -// RemoveAll -SL_LIST_TEMPLATE_LIST -void -SL_LIST_CLASS_NAME::RemoveAll() -{ - for (Node *node = fHead; node; ) { - Node *next = node->next; - fNodeAllocator.Free(node); - node = next; - } - fHead = NULL; -} - -// Find -SL_LIST_TEMPLATE_LIST -bool -SL_LIST_CLASS_NAME::Find(const Value &value, Iterator *iterator) const -{ - Node *node = fHead; - Node *previous = NULL; - while (node && fGetValue(node) != value) { - previous = node; - node = node->next; - } - if (node && iterator) { - iterator->_SetTo(const_cast(this), previous, - node); - } - return node; -} - -// GetIterator -SL_LIST_TEMPLATE_LIST -void -SL_LIST_CLASS_NAME::GetIterator(Iterator *iterator) const -{ - if (iterator) - iterator->_SetTo(const_cast(this), NULL, fHead); -} - -#endif // SL_LIST_H