From 7cb42b6167ddd931506af1aa3f5de89ad4304b84 Mon Sep 17 00:00:00 2001 From: Tyler Dauwalder Date: Tue, 9 Sep 2003 06:17:44 +0000 Subject: [PATCH] Switched to SinglyLinkedList.h git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4599 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/udf/PartitionMap.cpp | 42 ++++++++----------- .../kernel/file_systems/udf/PartitionMap.h | 8 ++-- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/add-ons/kernel/file_systems/udf/PartitionMap.cpp b/src/add-ons/kernel/file_systems/udf/PartitionMap.cpp index a712c55a31..e30cc116ff 100644 --- a/src/add-ons/kernel/file_systems/udf/PartitionMap.cpp +++ b/src/add-ons/kernel/file_systems/udf/PartitionMap.cpp @@ -18,21 +18,15 @@ PartitionMap::dump() PRINT(("fCount: %ld\n", fCount)); PRINT(("fList:\n")); - SLList::Iterator i; - fList.GetIterator(&i); - if (i.GetCurrent()) { - for (udf_partition_descriptor* partition = NULL; - (partition = i.GetCurrent()); - i.GetNext()) - { - PRINT((" partition #%d: start: %ld, length: %ld\n", partition->partition_number(), - partition->start(), partition->length())); - } - + SinglyLinkedList::Iterator i = fList.Begin(); + if (i != fList.End()) { + for ( ; i != fList.End(); ++i) { + PRINT((" partition #%d: start: %ld, length: %ld\n", i->partition_number(), + i->start(), i->length())); + } } else { PRINT((" (empty)\n")); - } - + } } @@ -45,11 +39,11 @@ PartitionMap::Add(const udf_partition_descriptor* partition) { status_t err = partition ? B_OK : B_BAD_VALUE; if (!err) { - udf_partition_descriptor *temp = Find(partition->partition_number()); + udf_partition_descriptor *temp = const_cast(Find(partition->partition_number())); if (temp) { *temp = *partition; } else { - err = fList.Insert(*partition) ? B_OK : B_ERROR; + err = fList.PushBack(*partition) ? B_OK : B_ERROR; } } return err; @@ -58,21 +52,19 @@ PartitionMap::Add(const udf_partition_descriptor* partition) /*! \brief Returns a pointer to the partition in the list with the given number, or NULL if no such partition exists. */ -udf_partition_descriptor* +const udf_partition_descriptor* PartitionMap::Find(uint32 partitionNumber) const { - udf_partition_descriptor *partition; - SLList::Iterator i; - fList.GetIterator(&i); - while ((partition = i.GetCurrent()) - && partition->partition_number() != partitionNumber) - { - i.GetNext(); + SinglyLinkedList::ConstIterator i; + for (i = fList.Begin(); i != fList.End(); ++i) { + if (i->partition_number() == partitionNumber) { + return &(*i); + } } - return partition; + return NULL; } -udf_partition_descriptor* +const udf_partition_descriptor* PartitionMap::operator[](uint32 partitionNumber) const { return Find(partitionNumber); diff --git a/src/add-ons/kernel/file_systems/udf/PartitionMap.h b/src/add-ons/kernel/file_systems/udf/PartitionMap.h index afaa9ae9c7..856c6ce7c4 100644 --- a/src/add-ons/kernel/file_systems/udf/PartitionMap.h +++ b/src/add-ons/kernel/file_systems/udf/PartitionMap.h @@ -14,7 +14,7 @@ #include "UdfDebug.h" #include "DiskStructures.h" -#include "SLList.h" +#include "SinglyLinkedList.h" namespace Udf { @@ -23,12 +23,12 @@ public: PartitionMap(); status_t Add(const udf_partition_descriptor* partition); - udf_partition_descriptor* Find(uint32 partitionNumber) const; - udf_partition_descriptor* operator[](uint32 partitionNumber) const; + const udf_partition_descriptor* Find(uint32 partitionNumber) const; + const udf_partition_descriptor* operator[](uint32 partitionNumber) const; void dump(); private: - SLList fList; + SinglyLinkedList fList; uint32 fCount; };