-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
275 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* (C) Copyright 1996- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation nor | ||
* does it submit to any jurisdiction. | ||
*/ | ||
|
||
|
||
#include "eckit/geometry/iterator/ListI.h" | ||
|
||
#include <type_traits> | ||
|
||
#include "eckit/geometry/Grid.h" | ||
|
||
|
||
namespace eckit::geometry::iterator { | ||
|
||
|
||
ListI::ListI(const Grid& grid) : | ||
Iterator(grid), | ||
points_(grid.to_points()), | ||
index_(0) { | ||
} | ||
|
||
|
||
bool ListI::operator==(const Iterator& other) { | ||
const auto* another = dynamic_cast<const ListI*>(&other); | ||
return another != nullptr && points_.data() == another->points_.data() && index_ == another->index_; | ||
} | ||
|
||
|
||
bool ListI::operator++() { | ||
++index_; | ||
return operator bool(); | ||
} | ||
|
||
|
||
bool ListI::operator--() { | ||
if (index_ == 0) { | ||
return false; | ||
} | ||
index_--; | ||
return operator bool(); | ||
} | ||
|
||
|
||
ListI::operator bool() { | ||
return index_ < points_.size(); | ||
} | ||
|
||
|
||
const Point& ListI::operator*() { | ||
ASSERT(operator bool()); | ||
return points_[index_]; | ||
} | ||
|
||
|
||
size_t ListI::size() const { | ||
return points_.size(); | ||
} | ||
|
||
|
||
size_t ListI::index() const { | ||
return index_; | ||
} | ||
|
||
|
||
} // namespace eckit::geometry::iterator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* (C) Copyright 1996- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation nor | ||
* does it submit to any jurisdiction. | ||
*/ | ||
|
||
|
||
#pragma once | ||
|
||
#include "eckit/geometry/Iterator.h" | ||
|
||
|
||
namespace eckit::geometry::iterator { | ||
|
||
|
||
class ListI final : public Iterator { | ||
public: | ||
// -- Types | ||
// None | ||
|
||
// -- Exceptions | ||
// None | ||
|
||
// -- Constructors | ||
|
||
explicit ListI(const Grid&); | ||
|
||
// -- Destructor | ||
// None | ||
|
||
// -- Convertors | ||
// None | ||
|
||
// -- Operators | ||
// None | ||
|
||
// -- Methods | ||
// None | ||
|
||
// -- Overridden methods | ||
// None | ||
|
||
// -- Class members | ||
// None | ||
|
||
// -- Class methods | ||
// None | ||
|
||
private: | ||
// -- Members | ||
|
||
const std::vector<Point>& points_; | ||
size_t index_; | ||
|
||
// -- Methods | ||
// None | ||
|
||
// -- Overridden methods | ||
|
||
bool operator==(const Iterator&) override; | ||
bool operator++() override; | ||
bool operator--() override; | ||
|
||
explicit operator bool() override; | ||
const Point& operator*() override; | ||
|
||
size_t size() const override; | ||
size_t index() const override; | ||
|
||
// -- Class members | ||
// None | ||
|
||
// -- Class methods | ||
// None | ||
|
||
// -- Friends | ||
// None | ||
}; | ||
|
||
|
||
} // namespace eckit::geometry::iterator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.