previous chapter contents page top page next chapter

HasCount

January 21, 1994

Defined in List.Def 
Mixes in with Object

Class Description

The HasCount mixin provides you with a way to associate the concept of a count to a collection of objects. How you implement the count is up to you.

Remember that if the documentation and the software (especially the definition files) disagree, always trust the software.

Mixing in HasCount

The HasCount mixin is a very small mixin used by a large set of classes. All of the list classes inherit from HasCount, for example. You might use the HasCount mixin while creating your own classes, but it's most likely you'll encounter it while using one of the many system-defined classes that inherit from it.

Programming Information

Instantiate: never
Subclass: always
Call its methods: sometimes

If you are creating a subclass using the HasCount mixin directly, you will need to redefine the Count attribute and implement a Count method. Many implementors of Count add a count field to their subclass definition, and simply define Count to return the contents of the field.

Methods you might call

The HasCount mixin has the following methods you might call:

Method Description
Count Get the count attribute
Empty Check to see if count is zero

Method Descriptions

Count

attribute Count: Unsigned, readOnly, safe, noGetter;
// operation Count(): Unsigned

call: sometimes
Override: always

The HasCount mixin does not define the Count method. If you create your own subclass using it, you'll want to redefine the Count attribute and write your own method.

Empty

attribute Empty: Boolean, readOnly;
// operation Empty(): Boolean

call: sometimes
Override: rarely

Empty calls Count, and returns true if Count returns zero.