SinglyLinkedList: The sole Iterator is really ConstIterator.
It behaves the same way as DoublyLinkedList's ConstIterator, so let's name it the same way for consistency.
This commit is contained in:
@@ -97,16 +97,16 @@ class SinglyLinkedList {
|
|||||||
typedef SinglyLinkedListLink<Element> Link;
|
typedef SinglyLinkedListLink<Element> Link;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Iterator {
|
class ConstIterator {
|
||||||
public:
|
public:
|
||||||
Iterator(const List* list)
|
ConstIterator(const List* list)
|
||||||
:
|
:
|
||||||
fList(list)
|
fList(list)
|
||||||
{
|
{
|
||||||
Rewind();
|
Rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator(const Iterator& other)
|
ConstIterator(const ConstIterator& other)
|
||||||
{
|
{
|
||||||
*this = other;
|
*this = other;
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ class SinglyLinkedList {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator& operator=(const Iterator& other)
|
ConstIterator& operator=(const ConstIterator& other)
|
||||||
{
|
{
|
||||||
fList = other.fList;
|
fList = other.fList;
|
||||||
fNext = other.fNext;
|
fNext = other.fNext;
|
||||||
@@ -160,10 +160,10 @@ class SinglyLinkedList {
|
|||||||
|
|
||||||
inline Element* GetNext(Element* element) const;
|
inline Element* GetNext(Element* element) const;
|
||||||
|
|
||||||
inline int32_t Size() const;
|
inline int32_t Count() const;
|
||||||
// O(n)!
|
// O(n)!
|
||||||
|
|
||||||
inline Iterator GetIterator() const { return Iterator(this); }
|
inline ConstIterator GetIterator() const { return ConstIterator(this); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element *fFirst;
|
Element *fFirst;
|
||||||
@@ -247,7 +247,7 @@ SINGLY_LINKED_LIST_CLASS_NAME::GetNext(Element* element) const
|
|||||||
// Size
|
// Size
|
||||||
SINGLY_LINKED_LIST_TEMPLATE_LIST
|
SINGLY_LINKED_LIST_TEMPLATE_LIST
|
||||||
int32_t
|
int32_t
|
||||||
SINGLY_LINKED_LIST_CLASS_NAME::Size() const
|
SINGLY_LINKED_LIST_CLASS_NAME::Count() const
|
||||||
{
|
{
|
||||||
int32_t count = 0;
|
int32_t count = 0;
|
||||||
for (Element* element = First(); element; element = GetNext(element))
|
for (Element* element = First(); element; element = GetNext(element))
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ private:
|
|||||||
|
|
||||||
class PathBlocklist {
|
class PathBlocklist {
|
||||||
public:
|
public:
|
||||||
typedef SinglyLinkedList<BlockedPath>::Iterator Iterator;
|
typedef SinglyLinkedList<BlockedPath>::ConstIterator Iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PathBlocklist();
|
PathBlocklist();
|
||||||
|
|||||||
@@ -94,16 +94,16 @@ class SinglyLinkedList {
|
|||||||
typedef SinglyLinkedListLink<Element> Link;
|
typedef SinglyLinkedListLink<Element> Link;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Iterator {
|
class ConstIterator {
|
||||||
public:
|
public:
|
||||||
Iterator(const List* list)
|
ConstIterator(const List* list)
|
||||||
:
|
:
|
||||||
fList(list)
|
fList(list)
|
||||||
{
|
{
|
||||||
Rewind();
|
Rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator(const Iterator& other)
|
ConstIterator(const ConstIterator& other)
|
||||||
{
|
{
|
||||||
*this = other;
|
*this = other;
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ class SinglyLinkedList {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator& operator=(const Iterator& other)
|
ConstIterator& operator=(const ConstIterator& other)
|
||||||
{
|
{
|
||||||
fList = other.fList;
|
fList = other.fList;
|
||||||
fNext = other.fNext;
|
fNext = other.fNext;
|
||||||
@@ -164,7 +164,7 @@ class SinglyLinkedList {
|
|||||||
inline int32 Count() const;
|
inline int32 Count() const;
|
||||||
// O(n)!
|
// O(n)!
|
||||||
|
|
||||||
inline Iterator GetIterator() const { return Iterator(this); }
|
inline ConstIterator GetIterator() const { return ConstIterator(this); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element *fFirst;
|
Element *fFirst;
|
||||||
|
|||||||
@@ -625,7 +625,7 @@ BPlusTree::~BPlusTree()
|
|||||||
// traversing the tree - a TreeIterator doesn't lock the inode)
|
// traversing the tree - a TreeIterator doesn't lock the inode)
|
||||||
mutex_lock(&fIteratorLock);
|
mutex_lock(&fIteratorLock);
|
||||||
|
|
||||||
SinglyLinkedList<TreeIterator>::Iterator iterator
|
SinglyLinkedList<TreeIterator>::ConstIterator iterator
|
||||||
= fIterators.GetIterator();
|
= fIterators.GetIterator();
|
||||||
while (iterator.HasNext())
|
while (iterator.HasNext())
|
||||||
iterator.Next()->Stop();
|
iterator.Next()->Stop();
|
||||||
@@ -983,7 +983,7 @@ BPlusTree::_UpdateIterators(off_t offset, off_t nextOffset, uint16 keyIndex,
|
|||||||
// any time, so we need to protect this loop
|
// any time, so we need to protect this loop
|
||||||
MutexLocker _(fIteratorLock);
|
MutexLocker _(fIteratorLock);
|
||||||
|
|
||||||
SinglyLinkedList<TreeIterator>::Iterator iterator
|
SinglyLinkedList<TreeIterator>::ConstIterator iterator
|
||||||
= fIterators.GetIterator();
|
= fIterators.GetIterator();
|
||||||
while (iterator.HasNext())
|
while (iterator.HasNext())
|
||||||
iterator.Next()->Update(offset, nextOffset, keyIndex, splitAt, change);
|
iterator.Next()->Update(offset, nextOffset, keyIndex, splitAt, change);
|
||||||
|
|||||||
@@ -649,7 +649,7 @@ Inode::_RemoveSmallData(bfs_inode* node, small_data* item, int32 index)
|
|||||||
memset(item, 0, item->Size());
|
memset(item, 0, item->Size());
|
||||||
|
|
||||||
// update all current iterators
|
// update all current iterators
|
||||||
SinglyLinkedList<AttributeIterator>::Iterator iterator
|
SinglyLinkedList<AttributeIterator>::ConstIterator iterator
|
||||||
= fIterators.GetIterator();
|
= fIterators.GetIterator();
|
||||||
while (iterator.HasNext()) {
|
while (iterator.HasNext()) {
|
||||||
iterator.Next()->Update(index, -1);
|
iterator.Next()->Update(index, -1);
|
||||||
@@ -853,7 +853,7 @@ Inode::_AddSmallData(Transaction& transaction, NodeGetter& nodeGetter,
|
|||||||
memset(item, 0, (uint8*)node + fVolume->InodeSize() - (uint8*)item);
|
memset(item, 0, (uint8*)node + fVolume->InodeSize() - (uint8*)item);
|
||||||
|
|
||||||
// update all current iterators
|
// update all current iterators
|
||||||
SinglyLinkedList<AttributeIterator>::Iterator iterator
|
SinglyLinkedList<AttributeIterator>::ConstIterator iterator
|
||||||
= fIterators.GetIterator();
|
= fIterators.GetIterator();
|
||||||
while (iterator.HasNext()) {
|
while (iterator.HasNext()) {
|
||||||
iterator.Next()->Update(index, 1);
|
iterator.Next()->Update(index, 1);
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ BTree::~BTree()
|
|||||||
// traversing the tree - a TreeIterator doesn't lock the inode)
|
// traversing the tree - a TreeIterator doesn't lock the inode)
|
||||||
mutex_lock(&fIteratorLock);
|
mutex_lock(&fIteratorLock);
|
||||||
|
|
||||||
SinglyLinkedList<TreeIterator>::Iterator iterator
|
SinglyLinkedList<TreeIterator>::ConstIterator iterator
|
||||||
= fIterators.GetIterator();
|
= fIterators.GetIterator();
|
||||||
while (iterator.HasNext())
|
while (iterator.HasNext())
|
||||||
iterator.Next()->Stop();
|
iterator.Next()->Stop();
|
||||||
|
|||||||
@@ -1342,7 +1342,7 @@ Inode::RemoveAttribute(const char* name, bool checkNamespace)
|
|||||||
if (checkNamespace && attribute->IsProtectedNamespace())
|
if (checkNamespace && attribute->IsProtectedNamespace())
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
// look for attribute in cookies
|
// look for attribute in cookies
|
||||||
AttrCookieList::Iterator i = fAttrCookies.GetIterator();
|
AttrCookieList::ConstIterator i = fAttrCookies.GetIterator();
|
||||||
while (i.HasNext()) {
|
while (i.HasNext()) {
|
||||||
attr_cookie* cookie = i.Next();
|
attr_cookie* cookie = i.Next();
|
||||||
if (cookie->current == attribute) {
|
if (cookie->current == attribute) {
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ DirectoryCache::RemoveEntry(const char* name)
|
|||||||
{
|
{
|
||||||
ASSERT(name != NULL);
|
ASSERT(name != NULL);
|
||||||
|
|
||||||
SinglyLinkedList<NameCacheEntry>::Iterator iterator
|
SinglyLinkedList<NameCacheEntry>::ConstIterator iterator
|
||||||
= fNameCache.GetIterator();
|
= fNameCache.GetIterator();
|
||||||
NameCacheEntry* previous = NULL;
|
NameCacheEntry* previous = NULL;
|
||||||
NameCacheEntry* current = iterator.Next();
|
NameCacheEntry* current = iterator.Next();
|
||||||
@@ -277,11 +277,11 @@ DirectoryCache::NotifyChanges(DirectoryCacheSnapshot* oldSnapshot,
|
|||||||
|
|
||||||
MutexLocker _(newSnapshot->fLock);
|
MutexLocker _(newSnapshot->fLock);
|
||||||
|
|
||||||
SinglyLinkedList<NameCacheEntry>::Iterator oldIt
|
SinglyLinkedList<NameCacheEntry>::ConstIterator oldIt
|
||||||
= oldSnapshot->fEntries.GetIterator();
|
= oldSnapshot->fEntries.GetIterator();
|
||||||
NameCacheEntry* oldCurrent;
|
NameCacheEntry* oldCurrent;
|
||||||
|
|
||||||
SinglyLinkedList<NameCacheEntry>::Iterator newIt
|
SinglyLinkedList<NameCacheEntry>::ConstIterator newIt
|
||||||
= newSnapshot->fEntries.GetIterator();
|
= newSnapshot->fEntries.GetIterator();
|
||||||
NameCacheEntry* newCurrent = newIt.Next();
|
NameCacheEntry* newCurrent = newIt.Next();
|
||||||
while (newCurrent != NULL) {
|
while (newCurrent != NULL) {
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ AttributeIndex::NodeChanged(Node* node, uint32 statFields,
|
|||||||
|
|
||||||
// move the iterators that point to the node to the previous node
|
// move the iterators that point to the node to the previous node
|
||||||
if (oldTreeValue != NULL) {
|
if (oldTreeValue != NULL) {
|
||||||
for (IteratorList::Iterator it = iterators.GetIterator();
|
for (IteratorList::ConstIterator it = iterators.GetIterator();
|
||||||
Iterator* iterator = it.Next();) {
|
Iterator* iterator = it.Next();) {
|
||||||
iterator->NodeChangeBegin(node);
|
iterator->NodeChangeBegin(node);
|
||||||
}
|
}
|
||||||
@@ -359,7 +359,7 @@ AttributeIndex::NodeChanged(Node* node, uint32 statFields,
|
|||||||
// its place, they will point to it again, otherwise to the node originally
|
// its place, they will point to it again, otherwise to the node originally
|
||||||
// succeeding it.
|
// succeeding it.
|
||||||
if (oldTreeValue != NULL) {
|
if (oldTreeValue != NULL) {
|
||||||
for (IteratorList::Iterator it = iterators.GetIterator();
|
for (IteratorList::ConstIterator it = iterators.GetIterator();
|
||||||
Iterator* iterator = it.Next();) {
|
Iterator* iterator = it.Next();) {
|
||||||
iterator->NodeChangeEnd(node);
|
iterator->NodeChangeEnd(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ LastModifiedIndex::NodeChanged(Node* node, uint32 statFields,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// move the iterators that point to the node to the previous node
|
// move the iterators that point to the node to the previous node
|
||||||
for (IteratorList::Iterator it = iterators.GetIterator();
|
for (IteratorList::ConstIterator it = iterators.GetIterator();
|
||||||
Iterator* iterator = it.Next();) {
|
Iterator* iterator = it.Next();) {
|
||||||
iterator->NodeChangeBegin(node);
|
iterator->NodeChangeBegin(node);
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ LastModifiedIndex::NodeChanged(Node* node, uint32 statFields,
|
|||||||
// Move the iterators to the next node again. If the node hasn't changed
|
// Move the iterators to the next node again. If the node hasn't changed
|
||||||
// its place, they will point to it again, otherwise to the node originally
|
// its place, they will point to it again, otherwise to the node originally
|
||||||
// succeeding it.
|
// succeeding it.
|
||||||
for (IteratorList::Iterator it = iterators.GetIterator();
|
for (IteratorList::ConstIterator it = iterators.GetIterator();
|
||||||
Iterator* iterator = it.Next();) {
|
Iterator* iterator = it.Next();) {
|
||||||
iterator->NodeChangeEnd(node);
|
iterator->NodeChangeEnd(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ SizeIndex::NodeChanged(Node* node, uint32 statFields,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// move the iterators that point to the node to the previous node
|
// move the iterators that point to the node to the previous node
|
||||||
for (IteratorList::Iterator it = iterators.GetIterator();
|
for (IteratorList::ConstIterator it = iterators.GetIterator();
|
||||||
Iterator* iterator = it.Next();) {
|
Iterator* iterator = it.Next();) {
|
||||||
iterator->NodeChangeBegin(node);
|
iterator->NodeChangeBegin(node);
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ SizeIndex::NodeChanged(Node* node, uint32 statFields,
|
|||||||
// Move the iterators to the next node again. If the node hasn't changed
|
// Move the iterators to the next node again. If the node hasn't changed
|
||||||
// its place, they will point to it again, otherwise to the node originally
|
// its place, they will point to it again, otherwise to the node originally
|
||||||
// succeeding it.
|
// succeeding it.
|
||||||
for (IteratorList::Iterator it = iterators.GetIterator();
|
for (IteratorList::ConstIterator it = iterators.GetIterator();
|
||||||
Iterator* iterator = it.Next();) {
|
Iterator* iterator = it.Next();) {
|
||||||
iterator->NodeChangeEnd(node);
|
iterator->NodeChangeEnd(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ UnpackingLeafNode::RemovePackageNode(PackageNode* packageNode, dev_t deviceID)
|
|||||||
// is not sorted)
|
// is not sorted)
|
||||||
PackageLeafNode* newestNode = fPackageNodes.Head();
|
PackageLeafNode* newestNode = fPackageNodes.Head();
|
||||||
if (isNewest && newestNode != NULL) {
|
if (isNewest && newestNode != NULL) {
|
||||||
PackageLeafNodeList::Iterator it = fPackageNodes.GetIterator();
|
PackageLeafNodeList::ConstIterator it = fPackageNodes.GetIterator();
|
||||||
it.Next();
|
it.Next();
|
||||||
// skip the first one
|
// skip the first one
|
||||||
while (PackageLeafNode* otherNode = it.Next()) {
|
while (PackageLeafNode* otherNode = it.Next()) {
|
||||||
|
|||||||
@@ -994,7 +994,7 @@ Volume::_AddPackageContent(Package* package, bool notify)
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
|
|
||||||
for (PackageNodeList::Iterator it = package->Nodes().GetIterator();
|
for (PackageNodeList::ConstIterator it = package->Nodes().GetIterator();
|
||||||
PackageNode* node = it.Next();) {
|
PackageNode* node = it.Next();) {
|
||||||
// skip over ".PackageInfo" file, it isn't part of the package content
|
// skip over ".PackageInfo" file, it isn't part of the package content
|
||||||
if (strcmp(node->Name(),
|
if (strcmp(node->Name(),
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ PathBlocklist::MakeEmpty()
|
|||||||
BlockedPath*
|
BlockedPath*
|
||||||
PathBlocklist::_FindPath(const char* path) const
|
PathBlocklist::_FindPath(const char* path) const
|
||||||
{
|
{
|
||||||
for (PathList::Iterator it = fPaths.GetIterator(); it.HasNext();) {
|
for (PathList::ConstIterator it = fPaths.GetIterator(); it.HasNext();) {
|
||||||
BlockedPath* blockedPath = it.Next();
|
BlockedPath* blockedPath = it.Next();
|
||||||
if (*blockedPath == path)
|
if (*blockedPath == path)
|
||||||
return blockedPath;
|
return blockedPath;
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ ARMPagingStructures32Bit::UpdateAllPageDirs(int index,
|
|||||||
{
|
{
|
||||||
InterruptsSpinLocker locker(sPagingStructuresListLock);
|
InterruptsSpinLocker locker(sPagingStructuresListLock);
|
||||||
|
|
||||||
PagingStructuresList::Iterator it = sPagingStructuresList.GetIterator();
|
PagingStructuresList::ConstIterator it = sPagingStructuresList.GetIterator();
|
||||||
while (ARMPagingStructures32Bit* info = it.Next())
|
while (ARMPagingStructures32Bit* info = it.Next())
|
||||||
info->pgdir_virt[index] = entry;
|
info->pgdir_virt[index] = entry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ X86PagingStructures32Bit::UpdateAllPageDirs(int index,
|
|||||||
{
|
{
|
||||||
InterruptsSpinLocker locker(sPagingStructuresListLock);
|
InterruptsSpinLocker locker(sPagingStructuresListLock);
|
||||||
|
|
||||||
PagingStructuresList::Iterator it = sPagingStructuresList.GetIterator();
|
PagingStructuresList::ConstIterator it = sPagingStructuresList.GetIterator();
|
||||||
while (X86PagingStructures32Bit* info = it.Next())
|
while (X86PagingStructures32Bit* info = it.Next())
|
||||||
info->pgdir_virt[index] = entry;
|
info->pgdir_virt[index] = entry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ VMArea::Init(const char* name, uint32 allocationFlags)
|
|||||||
bool
|
bool
|
||||||
VMArea::IsWired(addr_t base, size_t size) const
|
VMArea::IsWired(addr_t base, size_t size) const
|
||||||
{
|
{
|
||||||
for (VMAreaWiredRangeList::Iterator it = fWiredRanges.GetIterator();
|
for (VMAreaWiredRangeList::ConstIterator it = fWiredRanges.GetIterator();
|
||||||
VMAreaWiredRange* range = it.Next();) {
|
VMAreaWiredRange* range = it.Next();) {
|
||||||
if (range->IntersectsWith(base, size))
|
if (range->IntersectsWith(base, size))
|
||||||
return true;
|
return true;
|
||||||
@@ -123,7 +123,7 @@ VMArea::Unwire(VMAreaWiredRange* range)
|
|||||||
VMAreaWiredRange*
|
VMAreaWiredRange*
|
||||||
VMArea::Unwire(addr_t base, size_t size, bool writable)
|
VMArea::Unwire(addr_t base, size_t size, bool writable)
|
||||||
{
|
{
|
||||||
for (VMAreaWiredRangeList::Iterator it = fWiredRanges.GetIterator();
|
for (VMAreaWiredRangeList::ConstIterator it = fWiredRanges.GetIterator();
|
||||||
VMAreaWiredRange* range = it.Next();) {
|
VMAreaWiredRange* range = it.Next();) {
|
||||||
if (range->implicit && range->base == base && range->size == size
|
if (range->implicit && range->base == base && range->size == size
|
||||||
&& range->writable == writable) {
|
&& range->writable == writable) {
|
||||||
@@ -177,7 +177,7 @@ bool
|
|||||||
VMArea::AddWaiterIfWired(VMAreaUnwiredWaiter* waiter, addr_t base, size_t size,
|
VMArea::AddWaiterIfWired(VMAreaUnwiredWaiter* waiter, addr_t base, size_t size,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
{
|
{
|
||||||
for (VMAreaWiredRangeList::Iterator it = fWiredRanges.GetIterator();
|
for (VMAreaWiredRangeList::ConstIterator it = fWiredRanges.GetIterator();
|
||||||
VMAreaWiredRange* range = it.Next();) {
|
VMAreaWiredRange* range = it.Next();) {
|
||||||
if ((flags & IGNORE_WRITE_WIRED_RANGES) != 0 && range->writable)
|
if ((flags & IGNORE_WRITE_WIRED_RANGES) != 0 && range->writable)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user