You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
4 years ago
|
/**
|
||
4 years ago
|
* Acedia provides a small set of collections for easier data storage.
|
||
|
* This is their base class that provides a simple interface for
|
||
|
* common methods.
|
||
4 years ago
|
* Copyright 2020 Anton Tarasenko
|
||
|
*------------------------------------------------------------------------------
|
||
|
* This file is part of Acedia.
|
||
|
*
|
||
|
* Acedia is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* Acedia is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
|
||
|
*/
|
||
4 years ago
|
class Collection extends AcediaObject
|
||
4 years ago
|
abstract;
|
||
|
|
||
4 years ago
|
var class<Iter> iteratorClass;
|
||
4 years ago
|
|
||
4 years ago
|
/**
|
||
|
* Creates an `Iterator` instance to iterate over stored items.
|
||
|
*
|
||
|
* Returned `Iterator` must be manually deallocated after it was used.
|
||
|
*
|
||
|
* @return New initialized `Iterator` that will iterate over all items in
|
||
|
* a given collection. Guaranteed to be not `none`.
|
||
|
*/
|
||
|
public final function Iter Iterate()
|
||
4 years ago
|
{
|
||
4 years ago
|
local Iter newIterator;
|
||
|
newIterator = Iter(_.memory.Allocate(iteratorClass));
|
||
|
if (!newIterator.Initialize(self))
|
||
4 years ago
|
{
|
||
4 years ago
|
// This should not ever happen.
|
||
|
// If it does - it is a bug.
|
||
|
newIterator.FreeSelf();
|
||
|
return none;
|
||
4 years ago
|
}
|
||
4 years ago
|
return newIterator;
|
||
4 years ago
|
}
|
||
|
|
||
|
defaultproperties
|
||
|
{
|
||
|
}
|