Switched to SinglyLinkedList.h

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4599 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder
2003-09-09 06:17:44 +00:00
parent 2899835a86
commit 7cb42b6167
2 changed files with 21 additions and 29 deletions
@@ -18,21 +18,15 @@ PartitionMap::dump()
PRINT(("fCount: %ld\n", fCount)); PRINT(("fCount: %ld\n", fCount));
PRINT(("fList:\n")); PRINT(("fList:\n"));
SLList<udf_partition_descriptor>::Iterator i; SinglyLinkedList<Udf::udf_partition_descriptor>::Iterator i = fList.Begin();
fList.GetIterator(&i); if (i != fList.End()) {
if (i.GetCurrent()) { for ( ; i != fList.End(); ++i) {
for (udf_partition_descriptor* partition = NULL; PRINT((" partition #%d: start: %ld, length: %ld\n", i->partition_number(),
(partition = i.GetCurrent()); i->start(), i->length()));
i.GetNext()) }
{
PRINT((" partition #%d: start: %ld, length: %ld\n", partition->partition_number(),
partition->start(), partition->length()));
}
} else { } else {
PRINT((" (empty)\n")); PRINT((" (empty)\n"));
} }
} }
@@ -45,11 +39,11 @@ PartitionMap::Add(const udf_partition_descriptor* partition)
{ {
status_t err = partition ? B_OK : B_BAD_VALUE; status_t err = partition ? B_OK : B_BAD_VALUE;
if (!err) { if (!err) {
udf_partition_descriptor *temp = Find(partition->partition_number()); udf_partition_descriptor *temp = const_cast<udf_partition_descriptor*>(Find(partition->partition_number()));
if (temp) { if (temp) {
*temp = *partition; *temp = *partition;
} else { } else {
err = fList.Insert(*partition) ? B_OK : B_ERROR; err = fList.PushBack(*partition) ? B_OK : B_ERROR;
} }
} }
return err; 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 /*! \brief Returns a pointer to the partition in the list with the
given number, or NULL if no such partition exists. given number, or NULL if no such partition exists.
*/ */
udf_partition_descriptor* const udf_partition_descriptor*
PartitionMap::Find(uint32 partitionNumber) const PartitionMap::Find(uint32 partitionNumber) const
{ {
udf_partition_descriptor *partition; SinglyLinkedList<Udf::udf_partition_descriptor>::ConstIterator i;
SLList<udf_partition_descriptor>::Iterator i; for (i = fList.Begin(); i != fList.End(); ++i) {
fList.GetIterator(&i); if (i->partition_number() == partitionNumber) {
while ((partition = i.GetCurrent()) return &(*i);
&& partition->partition_number() != partitionNumber) }
{
i.GetNext();
} }
return partition; return NULL;
} }
udf_partition_descriptor* const udf_partition_descriptor*
PartitionMap::operator[](uint32 partitionNumber) const PartitionMap::operator[](uint32 partitionNumber) const
{ {
return Find(partitionNumber); return Find(partitionNumber);
@@ -14,7 +14,7 @@
#include "UdfDebug.h" #include "UdfDebug.h"
#include "DiskStructures.h" #include "DiskStructures.h"
#include "SLList.h" #include "SinglyLinkedList.h"
namespace Udf { namespace Udf {
@@ -23,12 +23,12 @@ public:
PartitionMap(); PartitionMap();
status_t Add(const udf_partition_descriptor* partition); status_t Add(const udf_partition_descriptor* partition);
udf_partition_descriptor* Find(uint32 partitionNumber) const; const udf_partition_descriptor* Find(uint32 partitionNumber) const;
udf_partition_descriptor* operator[](uint32 partitionNumber) const; const udf_partition_descriptor* operator[](uint32 partitionNumber) const;
void dump(); void dump();
private: private:
SLList<Udf::udf_partition_descriptor> fList; SinglyLinkedList<Udf::udf_partition_descriptor> fList;
uint32 fCount; uint32 fCount;
}; };