Dart Documentationbot_qrQrBitBuffer

QrBitBuffer class

class QrBitBuffer extends ListBase<bool> {
  final List<int> _buffer;
  int _length = 0;

  QrBitBuffer() : _buffer = new List<int>();

  bool operator[](int index) {
    final bufIndex = index ~/ 8;
    return ((_buffer[bufIndex] >> (7 - index % 8)) & 1) == 1;
  }

  int get length => _length;

  int getByte(int index) => _buffer[index];

  void put(int number, int length) {
    for(var i = 0; i < length; i++) {
      final bit = ((number >> (length - i - 1)) & 1) == 1;
      putBit(bit);
    }
  }

  void putBit(bool bit) {

    final bufIndex = _length ~/ 8;
    if (_buffer.length <= bufIndex) {
      _buffer.add(0);
    }

    if (bit) {
      _buffer[bufIndex] |= (0x80 >> (_length % 8));
    }

    _length++;
  }
}

Extends

Enumerable<T> > ListBase<T> > QrBitBuffer

Constructors

new QrBitBuffer() #

QrBitBuffer() : _buffer = new List<int>();

Properties

int get length #

Returns the number of elements in this collection.

docs inherited from ListBase<T>
int get length => _length;

void set length(int newLength) #

inherited from ListBase

Changes the length of the list. If newLength is greater than the current length, entries are initialized to null. Throws an UnsupportedOperationException if the list is not extendable.

docs inherited from List<E>
void set length(int newLength) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

final Type runtimeType #

inherited from Object

A representation of the runtime type of the object.

external Type get runtimeType;

Operators

bool operator [](int index) #

Returns the element at the given index in the list or throws an IndexOutOfRangeException if index is out of bounds.

docs inherited from ListBase<T>
bool operator[](int index) {
  final bufIndex = index ~/ 8;
  return ((_buffer[bufIndex] >> (7 - index % 8)) & 1) == 1;
}

void operator []=(int index, T value) #

inherited from ListBase

Sets the entry at the given index in the list to value. Throws an IndexOutOfRangeException if index is out of bounds.

docs inherited from List<E>
void operator []=(int index, T value) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

bool operator ==(other) #

inherited from Object

The equality operator.

The default behavior for all Objects is to return true if and only if this and other are the same object.

If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.

bool operator ==(other) => identical(this, other);

Methods

void add(T value) #

inherited from ListBase

Adds value at the end of the list, extending the length by one. Throws an UnsupportedOperationException if the list is not extendable.

docs inherited from List<E>
void add(T value) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

void addAll(Collection<T> value) #

inherited from ListBase

Appends all elements of the collection to the end of this list. Extends the length of the list by the number of elements in collection. Throws an UnsupportedOperationException if this list is not extendable.

docs inherited from List<E>
void addAll(Collection<T> value) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

void addLast(T value) #

inherited from ListBase

Adds value at the end of the list, extending the length by one. Throws an UnsupportedOperationException if the list is not extendable.

docs inherited from List<E>
void addLast(T value) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

Object aggregate(Object seed, Func2 f) #

inherited from Enumerable
Object aggregate(Object seed, Func2<Object, T, Object> f) {
  requireArgumentNotNull(f, 'f');
  return CollectionUtil.aggregate(this, seed, f);
}

void clear() #

inherited from ListBase

Removes all elements in the list.

The length of the list becomes zero. Throws an UnsupportedOperationException, and retains all elements, if the length of the list cannot be changed.

docs inherited from List<E>
void clear() {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

bool contains(T item) #

inherited from Enumerable
bool contains(T item) {
  for (final e in this) {
    if(e == item) {
      return true;
    }
  }
  return false;
}

int count([Func1 f = null]) #

inherited from Enumerable
int count([Func1<T, bool> f = null]) {
  if(f == null) {
    f = (a) => true;
  }
  int c = 0;
  for(final e in this) {
    if(f(e)) {
      c++;
    }
  }
  return c;
}

Enumerable<T> distinct([Func2 comparer = null]) #

inherited from Enumerable
Enumerable<T> distinct([Func2<T, T, bool> comparer = null]) {
  if(comparer == null) {
    comparer = (a,b) => a == b;
  }
  return new _FuncEnumerable(this, (s) => new _DistinctIterator(s, comparer));
}

const Enumerable() #

inherited from Enumerable
const Enumerable();

factory Enumerable.fromIterable(Iterable<T> source) #

inherited from Enumerable
factory Enumerable.fromIterable(Iterable<T> source) {
  requireArgumentNotNull(source, 'source');
  return new _SimpleEnumerable<T>(source);
}

bool every(bool f(T element)) #

inherited from ListBase

Returns true if every elements of this collection satisify the predicate f. Returns false otherwise.

bool every(bool f(T element)) {
  for (var i = 0; i < length; i++) {
    if(!f(this[i])) {
      return false;
    }
  }
  return true;
}

Enumerable<T> exclude(Iterable<T> items) #

inherited from Enumerable
Enumerable<T> exclude(Iterable<T> items) {
  requireArgumentNotNull(items, 'items');
  final iEnum = $(items);
  Func1<T, bool> f = (e) => !iEnum.contains(e);
  return new _FuncEnumerable(this, (s) => new _WhereIterator<T>(s, f));
}

Enumerable<T> filter(Func1 f) #

inherited from Enumerable

Returns a new collection with the elements of this collection that satisfy the predicate f.

An element satisfies the predicate f if f(element) returns true.

docs inherited from Collection<E>
Enumerable<T> filter(Func1<T, bool> f) {
  requireArgumentNotNull(f, 'f');
  return new _FuncEnumerable(this, (s) => new _WhereIterator<T>(s, f));
}

T first([Func1 f = null]) #

inherited from Enumerable
T first([Func1<T, bool> f = null]) {
  if(f == null) {
    f = (e) => true;
  }
  final iter = new _WhereIterator<T>(this.iterator(), f);
  if(!iter.hasNext()) {
    throw const InvalidOperationException('The input sequence is empty.');
  }
  return iter.next();
}

T firstOrDefault([Func1 f = null, T defaultValue = null]) #

inherited from Enumerable
T firstOrDefault([Func1<T, bool> f = null, T defaultValue = null]) {
  if(f == null) {
    f = (e) => true;
  }
  final iter = new _WhereIterator<T>(this.iterator(), f);
  if(!iter.hasNext()) {
    return defaultValue;
  }
  return iter.next();
}

void forEach(void f(T element)) #

inherited from ListBase

Applies the function f to each element of this collection.

void forEach(void f(T element)) {
  for(var i = 0; i < length; i++) {
    f(this[i]);
  }
}

void forEachWithIndex(Action2 f) #

inherited from Enumerable
void forEachWithIndex(Action2<T, int> f) {
  int i = 0;
  for(final e in this) {
    f(e, i++);
  }
}

int getByte(int index) #

int getByte(int index) => _buffer[index];

List<T> getRange(int start, int itemCount) #

inherited from ListBase

Returns a new list containing itemCount elements from the list, starting at start. Returns an empty list if itemCount is 0. Throws an IllegalArgumentException if itemCount is negative. Throws an IndexOutOfRangeException if start or start + itemCount - 1 are out of range.

List<T> getRange(int start, int itemCount)  {
  requireArgument(itemCount >= 0, 'count');

  final lastIndex = start + itemCount - 1;

  if(itemCount > 0) {
    if(start < 0) {
      throw new IndexOutOfRangeException(start);
    }
    else if(lastIndex >= length) {
      throw new IndexOutOfRangeException(lastIndex);
    }
  }

  var list = new List<T>();
  for(var i = start; i <= lastIndex; i++) {
    list.add(this[i]);
  }
  return list;
}

Grouping<Dynamic, T> group([Func1 keyFunc = null]) #

inherited from Enumerable
Grouping<Dynamic, T> group([Func1<T, Object> keyFunc = null]) {
  return new Grouping(this, keyFunc);
}

int hashCode() #

inherited from Object

Get a hash code for this object.

All objects have hash codes. Hash codes are guaranteed to be the same for objects that are equal when compared using the equality operator ==. Other than that there are no guarantees about the hash codes. They will not be consistent between runs and there are no distribution guarantees.

If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.

external int hashCode();

int indexOf(T element, [int start = 0]) #

inherited from ListBase

Returns the first index of element in the list. Searches the list from index start to the length of the list. Returns -1 if element is not found.

int indexOf(T element, [int start=0]) {
  for (var i = start; i < length; i++) {
    if(this[i] == element) {
      return i;
    }
  }
  return -1;
}

void insertRange(int start, int length, [T initialValue]) #

inherited from ListBase

Inserts a new range into the list, starting from start to start + length - 1. The entries are filled with initialValue. Throws an UnsupportedOperationException if the list is not extendable. If length is 0, this method does not do anything. If start is the length of the list, this method inserts the range at the end of the list. Throws an ArgumentError if length is negative. Throws an IndexOutOfRangeException if start is negative or if start is greater than the length of the list.

docs inherited from List<E>
void insertRange(int start, int length, [T initialValue]) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

bool isEmpty() #

inherited from ListBase

Returns true if there is no element in this collection.

bool isEmpty() => length == 0;

Iterator<T> iterator() #

inherited from ListBase

Returns an Iterator that iterates over this Iterable object.

Iterator<T> iterator() {
  return new IndexIterator<T>(length, (i) => this[i]);
}

String join([String separator = ', ']) #

inherited from Enumerable
String join([String separator = ', ']) {
  final StringBuffer sb = new StringBuffer();
  for(final e in this) {
    if(sb.length > 0) {
      sb.add(separator);
    }
    sb.add(e);
  }
  return sb.toString();
}

T last() #

inherited from ListBase

Returns the last element of the list, or throws an out of bounds exception if the list is empty.

T last() => this[this.length-1];

int lastIndexOf(T element, [int start = 0]) #

inherited from ListBase

Returns the last index of element in the list. Searches the list from index start to 0. Returns -1 if element is not found.

int lastIndexOf(T element, [int start=0]) {
  // DARTBUG: having trouble testing this in the compiler. :-/
  var lastIndex = -1;
  for (var i = start; i < length; i++) {
    if(this[i] == element) {
      lastIndex = i;
    }
  }
  return lastIndex;
}

new List([int length]) #

inherited from List

Creates a list of the given length.

If no length argument is supplied an extendable list of length 0 is created.

If a length argument is supplied, a fixed size list of that length is created.

List([int length]);

new List.from(Iterable<E> other) #

inherited from List

Creates a list with the elements of other. The order in the list will be the order provided by the iterator of other.

List.from(Iterable<E> other);

const ListBase() #

inherited from ListBase
const ListBase();

Enumerable map(Func1 f) #

inherited from Enumerable

Returns a new collection with the elements f(e) for each element e of this collection.

Note on typing: the return type of f() could be an arbitrary type and consequently the returned collection's typeis Collection.

Enumerable map(Func1<T, Object> f) {
  requireArgumentNotNull(f, 'f');
  return new _FuncEnumerable(this, (s) => new _SelectIterator<T, Object>(s, f));
}

noSuchMethod(String name, List args) #

inherited from Object

noSuchMethod is invoked when users invoke a non-existant method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod. If noSuchMethod returns a value, that value becomes the result of the original invocation.

The default behavior of noSuchMethod is to throw a noSuchMethodError.

external Dynamic noSuchMethod(String name, List args);

const Object() #

inherited from Object

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

const Object();

void put(int number, int length) #

void put(int number, int length) {
  for(var i = 0; i < length; i++) {
    final bit = ((number >> (length - i - 1)) & 1) == 1;
    putBit(bit);
  }
}

void putBit(bool bit) #

void putBit(bool bit) {

  final bufIndex = _length ~/ 8;
  if (_buffer.length <= bufIndex) {
    _buffer.add(0);
  }

  if (bit) {
    _buffer[bufIndex] |= (0x80 >> (_length % 8));
  }

  _length++;
}

new QrBitBuffer() #

QrBitBuffer() : _buffer = new List<int>();

reduce(initialValue, combine(previousValue, T element)) #

inherited from Enumerable

Reduce a collection to a single value by iteratively combining each element of the collection with an existing value using the provided function. Use initialValue as the initial value, and the function combine to create a new value from the previous one and an element.

Example of calculating the sum of a collection:

collection.reduce(0, (prev, element) => prev + element);

Dynamic reduce(Dynamic initialValue,
               Dynamic combine(Dynamic previousValue, T element)) {
  return Collections.reduce(this, initialValue, combine);
}

T removeAt(int index) #

inherited from ListBase

Removes the element at position index from the list.

This reduces the length of the list by one and moves all later elements down by one position. Returns the removed element. Throws an ArgumentError if index is not an int. Throws an IndexOutOfRangeException if the index does not point inside the list. Throws an UnsupportedOperationException, and doesn't remove the element, if the length of the list cannot be changed.

docs inherited from List<E>
T removeAt(int index) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

T removeLast() #

inherited from ListBase

Pops and returns the last element of the list. Throws a UnsupportedOperationException if the length of the list cannot be changed.

docs inherited from List<E>
T removeLast() {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

void removeRange(int start, int length) #

inherited from ListBase

Removes length elements from the list, beginning at start. Throws an UnsupportedOperationException if the list is not extendable. If length is 0, this method does not do anything. Throws an ArgumentError if length is negative. Throws an IndexOutOfRangeException if start or :start + length: - 1 are out of range.

docs inherited from List<E>
void removeRange(int start, int length) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

Enumerable selectMany(Func1 f) #

inherited from Enumerable
Enumerable selectMany(Func1<T, Iterable> f) {
  requireArgumentNotNull(f, 'f');
  return new _FuncEnumerable(this,
    (s) => new _SelectManyIterator._internal(s, f));
}

NumberEnumerable selectNumbers(Func1 f) #

inherited from Enumerable
NumberEnumerable selectNumbers(Func1<T, num> f) {
  requireArgumentNotNull(f, 'f');
  return new _FuncNumEnumerable<T>(this, (s) => new _SelectIterator<T, num>(s, f));
}

void setRange(int start, int length, List<T> from, [int startFrom]) #

inherited from ListBase

Copies length elements of from, starting at startFrom, into the list, starting at start. If length is 0, this method does not do anything. Throws an ArgumentError if length is negative. Throws an IndexOutOfRangeException if start or start + length - 1 are out of range for this, or if startFrom or startFrom + length - 1 are out of range for from.

docs inherited from List<E>
void setRange(int start, int length, List<T> from, [int startFrom]) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

T single([Func1 f = null]) #

inherited from Enumerable
T single([Func1<T, bool> f = null]) {
  if(f == null) {
    f = (e) => true;
  }
  final iter = new _WhereIterator<T>(this.iterator(), f);
  if(!iter.hasNext()) {
    throw const InvalidOperationException('The input sequence is empty.');
  }
  final value = iter.next();
  if(iter.hasNext()) {
    throw const InvalidOperationException('The input sequence contains more than one element.');
  }
  return value;
}

T singleOrDefault([Func1 f = null, T defaultValue = null]) #

inherited from Enumerable
T singleOrDefault([Func1<T, bool> f = null, T defaultValue = null]) {
  if(f == null) {
    f = (e) => true;
  }
  final iter = new _WhereIterator<T>(this.iterator(), f);
  if(!iter.hasNext()) {
    return defaultValue;
  }
  final value = iter.next();
  if(iter.hasNext()) {
    throw const InvalidOperationException('The input sequence contains more than one element.');
  }
  return value;
}

bool some(bool f(T element)) #

inherited from ListBase

Returns true if one element of this collection satisfies the predicate f. Returns false otherwise.

bool some(bool f(T element)) {
  for (var i = 0; i < length; i++) {
    if(f(this[i])) {
      return true;
    }
  }
  return false;
}

void sort(Func2 comparer) #

inherited from ListBase

Sorts the list according to the order specified by the Comparator.

docs inherited from List<E>
void sort(Func2<T,T,int> comparer) {
  throw const UnsupportedOperationException('Mutation operations are not supported');
}

HashMap toHashMap(Func1 valueFunc, [Func1 keyFunc]) #

inherited from Enumerable
HashMap toHashMap(Func1<T, Object> valueFunc, [Func1<T, Hashable> keyFunc]) {
  if(keyFunc == null) {
    keyFunc = (a) => a;
  }

  final map = new HashMap();
  for(final e in this) {
    final k = keyFunc(e);
    if(map.containsKey(k)) {
      throw new UnsupportedOperationException("The key '$k' is duplicated");
    }
    map[k] = valueFunc(e);
  }
  return map;
}

HashSet toHashSet([Func1 f]) #

inherited from Enumerable
HashSet toHashSet([Func1<T, Hashable> f]) {
  if(f == null) {
    return new HashSet.from(this);
  } else {
    return new HashSet.from(this.map(f));
  }
}

List<T> toList() #

inherited from Enumerable
List<T> toList() => new List<T>.from(this);

ReadOnlyCollection<T> toReadOnlyCollection() #

inherited from Enumerable
ReadOnlyCollection<T> toReadOnlyCollection() => new ReadOnlyCollection<T>(this);

String toString() #

inherited from Enumerable

Returns a string representation of this object.

docs inherited from Object
String toString() => "[${this.join()}]";