Added index iterators

Former-commit-id: de3ed77ba9e3c48aa68020e23ded679066b9878f
This commit is contained in:
Lynix
2013-06-05 15:33:43 +02:00
parent fbc0d7404e
commit 146ca80a63
7 changed files with 297 additions and 67 deletions

View File

@@ -0,0 +1,79 @@
// Copyright (C) 2013 Jérôme Leclercq
// This file is part of the "Nazara Engine - Utility module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_INDEXITERATOR_HPP
#define NAZARA_INDEXITERATOR_HPP
#include <Nazara/Prerequesites.hpp>
class NzIndexMapper;
class NzIndexIterator
{
friend NzIndexMapper;
public:
class Reference;
NzIndexIterator();
NzIndexIterator(const NzIndexIterator& iterator);
~NzIndexIterator() = default;
Reference operator*() const;
Reference operator[](unsigned int index) const;
NzIndexIterator& operator=(const NzIndexIterator& iterator);
NzIndexIterator operator+(unsigned int indexCount);
NzIndexIterator operator-(unsigned int indexCount);
NzIndexIterator& operator+=(unsigned int indexCount);
NzIndexIterator& operator-=(unsigned int indexCount);
NzIndexIterator& operator++();
NzIndexIterator operator++(int);
NzIndexIterator& operator--();
NzIndexIterator operator--(int);
friend bool operator==(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator!=(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator<(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator<=(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator>(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
friend bool operator>=(const NzIndexIterator& lhs, const NzIndexIterator& rhs);
private:
NzIndexIterator(NzIndexMapper* mapper, unsigned int index);
NzIndexMapper* m_mapper;
unsigned int m_index;
};
class NzIndexIterator::Reference
{
friend NzIndexIterator;
public:
Reference(const Reference& reference) = default;
~Reference() = default;
Reference& operator=(nzUInt32 value);
Reference& operator=(const Reference& reference);
operator nzUInt32() const;
private:
Reference(NzIndexMapper* mapper, unsigned int index);
NzIndexMapper* m_mapper;
unsigned int m_index;
};
#include <Nazara/Utility/IndexIterator.inl>
#endif // NAZARA_INDEXITERATOR_HPP