The "pif_Iterator class.dm" file defines the /pif_Iterator protocol class and details the protocol itself. Refer to this file for the protocol in full detail, but an abbreivation of it is here.
A particular Iterator class should be designed to only accept and 'understand' data from a given source. That is, there should be no "swiss-army knife" Iterator designed to work with any and every possible source of data. Make a given Iterator class do one thing and do it well.
The protocol consists of seven methods, along with the constructor. Their behavior is as follows.
- The Iterator class constructor should accept an argument indicating the data source to read from.
- The Iterator Initialize() method should be called to begin iterating through data from the source provided to the constructor.
- The Next() method moves to the 'next' piece of data from the data source, and returns either the new position or 0, if the end of the data has been reached. It may optionally take an argument indicating a position to move to.
- The Look() method gives the data from the source data at the current position.
- The Done() method returns true when the end of the data has been reached, and false otherwise.
- The Step() method moves the current position forward or backwards by a certain amount, as indicated by its argument. This method is optional.
- The Peek() method looks at the data in a position forward or backwards by a certain amount, as indicated by its argument. This method is optional.
- The Position() method indicates the current position in the data. If the data has no meaningful position, it may also be used as a counter, to indicate how much data has been moved through.
- ForwardListIterator and BackwardListIterator are iterators on the native DM /list object.
- The ForwardListIterator class iterates over a list from the first element to the last
- The BackwardListIterator class iterates over a list from the last element to the first.
- The RangeIterator class iterates over a used-specified range with an optional step size.
- The MethodIterator class iterates a supplied method or function over a specified domain.
- Reorganized files.
- Added MIT license to project, under "+License.dm".
- Updated documentation to reflect MIT license.
- Added /pif_Iterator/RangeIterator class.
- Added RangeIterator class documentation.
- Added /pif_Iterator/MethodIterator class.
- Added MethodIterator class documentation.
- Clarified protocol note for when methods are called before Initialize().
- Initial release.
Copyright (c) 2016-2019 Timothy "popisfizzy" Reilly Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.