Linter Demo Errors: 1Warnings: 30File: /home/fstrocco/Dart/dart/benchmark/compiler/lib/src/util/link_implementation.dart // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. part of util_implementation; class LinkIterator implements Iterator { T _current; Link _link; LinkIterator(Link this._link); T get current => _current; bool moveNext() { if (_link.isEmpty) { _current = null; return false; } _current = _link.head; _link = _link.tail; return true; } } typedef T Transformation(S input); class MappedLinkIterator extends Iterator { Transformation _transformation; Link _link; T _current; MappedLinkIterator(this._link, this._transformation); T get current => _current; bool moveNext() { if (_link.isEmpty) { _current = null; return false; } _current = _transformation(_link.head); _link = _link.tail; return true; } } class MappedLinkIterable extends IterableBase { Transformation _transformation; Link _link; MappedLinkIterable(this._link, this._transformation); Iterator get iterator { return new MappedLinkIterator(_link, _transformation); } } class LinkEntry extends Link { final T head; Link tail; LinkEntry(T this.head, [Link tail]) : this.tail = ((tail == null) ? new Link() : tail); Link prepend(T element) { // TODO(ahe): Use new Link, but this cost 8% performance on VM. return new LinkEntry(element, this); } void printOn(StringBuffer buffer, [separatedBy]) { buffer.write(head); if (separatedBy == null) separatedBy = ''; for (Link link = tail; !link.isEmpty; link = link.tail) { buffer.write(separatedBy); buffer.write(link.head); } } String toString() { StringBuffer buffer = new StringBuffer(); buffer.write('[ '); printOn(buffer, ', '); buffer.write(' ]'); return buffer.toString(); } Link reverse() { Link result = const Link(); for (Link link = this; !link.isEmpty; link = link.tail) { result = result.prepend(link.head); } return result; } Link reversePrependAll(Link from) { Link result; for (result = this; !from.isEmpty; from = from.tail) { result = result.prepend(from.head); } return result; } Link skip(int n) { Link link = this; for (int i = 0 ; i < n ; i++) { if (link.isEmpty) { throw new RangeError('Index $n out of range'); } link = link.tail; } return link; } bool get isEmpty => false; void forEach(void f(T element)) { for (Link link = this; !link.isEmpty; link = link.tail) { f(link.head); } } bool operator ==(other) { if (other is !Link) return false; Link myElements = this; while (!myElements.isEmpty && !other.isEmpty) { if (myElements.head != other.head) { return false; } myElements = myElements.tail; other = other.tail; } return myElements.isEmpty && other.isEmpty; } int get hashCode => throw new UnsupportedError('LinkEntry.hashCode'); int slowLength() => 1 + tail.slowLength(); Link copyWithout(e) { LinkBuilder copy = new LinkBuilder(); Link link = this; for (; !link.isEmpty; link = link.tail) { if (link.head != e) { copy.addLast(link.head); } } return copy.toLink(link); } } class LinkBuilderImplementation implements LinkBuilder { LinkEntry head = null; LinkEntry lastLink = null; int length = 0; LinkBuilderImplementation(); Link toLink([Link tail = const Link()]) { if (head == null) return tail; lastLink.tail = tail; Link link = head; lastLink = null; head = null; return link; } List toList() { if (length == 0) return new List(0); List list = new List(length); int index = 0; Link link = head; while (!link.isEmpty) { list[index] = link.head; link = link.tail; index++; } lastLink = null; head = null; return list; } void addLast(T t) { length++; LinkEntry entry = new LinkEntry(t, null); if (head == null) { head = entry; } else { lastLink.tail = entry; } lastLink = entry; } bool get isEmpty => length == 0; }