Reference » Collections and iterators » Collection

Elgrint::Collection class

Declared in MVector.h

Description

Generic collection (pseudo-class).
Read more...

Classes:

Name Description
CIter Generic constant iterator (pseudo-class) of a collection.
Iter Generic non-constant iterator (pseudo-class) of a collection.

Initializers:

Name Description
Collection() Default constructor - creates an empty collection.
Collection(source) Copy constructor - creates a copy of a collection. The copy is shared, if possible (see Details).
~Collection() Destructor - similar to reset (see).

Mutators:

Name Description
operator=(source) Copies the source collection into this (destination). Similar to a copy constructor.
reset() Makes the collection empty (just like the one being created by default constructor).
setError(err) Raises or lowers the error flag for this collection.
swapWith(c) Swaps the contents of two collections (very efficiently).

Revealers:

Name Description
cnt() Returns the current number of items in the collection.
isError() Returns true if the error flag of this collection has been raised (see setError).

Details

Even though collections are different, all share the same 9 common methods with exactly the same syntax and semantics (if "Collection" is replaced with the proper collection class name, of course), almost as if they were all derived from this Collection pseudo-class. In reality these methods are defined separately in each class (and may have very different implementations), but it is much easier in terms of learning the interface to imagine that the Collection class is a real base class for all collections. The same principle applies to CIter and Iter pseudo-classes (child classes of Collection). Even though Collection isn't really declared anywhere, MVector declaration (see the file link above) can be used as an example.

Remarks

Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.