Dart DocumentationdartemisReadOnlyBag<E>

ReadOnlyBag<E> class

A ReadOnlyBag offers a read-only view for an underlying Bag.

class ReadOnlyBag<E> {
 Bag<E> _bag;

 ReadOnlyBag._of(this._bag);

 /**
  * Returns the element at [index].
  */
 E operator [](int index) => _bag[index];

 /**
  * Returns the size of the underlying [Bag].
  */
 int get size => _bag.size;

 /**
  * Returns [:true:] if the underlying [Bag] is empty.
  */
 bool get isEmpty => _bag.isEmpty;

 /**
  * Returns [:true:] if the underlying [Bag] contains the [element].
  */
 bool contains(E element) => _bag.contains(element);

 /**
  * Applies the function [f] to each element the underlying [Bag].
  */
 void forEach(void f(E element)) => _bag.forEach(f);
}

Properties

final bool isEmpty #

Returns true if the underlying Bag is empty.

bool get isEmpty => _bag.isEmpty;

final int size #

Returns the size of the underlying Bag.

int get size => _bag.size;

Operators

E operator [](int index) #

Returns the element at index.

E operator [](int index) => _bag[index];

Methods

bool contains(E element) #

Returns true if the underlying Bag contains the element.

bool contains(E element) => _bag.contains(element);

void forEach(void f(E element)) #

Applies the function f to each element the underlying Bag.

void forEach(void f(E element)) => _bag.forEach(f);