| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | package org.apache.commons.collections4.list; | |
| 18 | ||
| 19 | import java.util.AbstractList; | |
| 20 | import java.util.ArrayDeque; | |
| 21 | import java.util.Collection; | |
| 22 | import java.util.ConcurrentModificationException; | |
| 23 | import java.util.Deque; | |
| 24 | import java.util.Iterator; | |
| 25 | import java.util.ListIterator; | |
| 26 | import java.util.NoSuchElementException; | |
| 27 | ||
| 28 | import org.apache.commons.collections4.OrderedIterator; | |
| 29 | ||
| 30 | /** | |
| 31 | * A List implementation that is optimised for fast insertions and | |
| 32 | * removals at any index in the list. | |
| 33 | *
 | |
| 34 | * This list implementation utilises a tree structure internally to ensure that | |
| 35 | * all insertions and removals are O(log n). This provides much faster performance | |
| 36 | * than both an ArrayList and a LinkedList where elements | |
| 37 | * are inserted and removed repeatedly from anywhere in the list. | |
| 38 | *
 | |
| 39 | * The following relative performance statistics are indicative of this class: | |
| 40 | *
 | |
| 41 | * get add insert iterate remove | |
| 42 | * TreeList 3 5 1 2 1 | |
| 43 | * ArrayList 1 1 40 1 40 | |
| 44 | * LinkedList 5800 1 350 2 325 | |
| 45 | *
 | |
| 46 | * ArrayList is a good general purpose list implementation. | |
| 47 | * It is faster than TreeList for most operations except inserting | |
| 48 | * and removing in the middle of the list. ArrayList also uses less | |
| 49 | * memory as TreeList uses one object per entry. | |
| 50 | *
 | |
| 51 | * LinkedList is rarely a good choice of implementation. | |
| 52 | * TreeList is almost always a good replacement for it, although it | |
| 53 | * does use slightly more memory. | |
| 54 | * | |
| 55 | * @since 3.1 | |
| 56 | * @version $Id: TreeList.java 1681434 2015-05-24 10:49:58Z tn $ | |
| 57 | */ | |
| 58 | public class TreeList<E> extends AbstractList<E> { | |
| 59 | // add; toArray; iterator; insert; get; indexOf; remove | |
| 60 | // TreeList = 1260;7360;3080; 160; 170;3400; 170; | |
| 61 | // ArrayList = 220;1480;1760; 6870; 50;1540; 7200; | |
| 62 | // LinkedList = 270;7360;3350;55860;290720;2910;55200; | |
| 63 | ||
| 64 | /** The root node in the AVL tree */ | |
| 65 | private AVLNode<E> root; | |
| 66 | ||
| 67 | /** The current size of the list */ | |
| 68 | private int size; | |
| 69 | ||
| 70 | //----------------------------------------------------------------------- | |
| 71 | /** | |
| 72 | * Constructs a new empty list. | |
| 73 | */ | |
| 74 | public TreeList() { | |
| 75 | super(); | |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * Constructs a new empty list that copies the specified collection. | |
| 80 | * | |
| 81 | * @param coll the collection to copy | |
| 82 | * @throws NullPointerException if the collection is null | |
| 83 | */ | |
| 84 | public TreeList(final Collection<? extends E> coll) { | |
| 85 | super(); | |
| 86 |
1
1. |
if (!coll.isEmpty()) { |
| 87 | root = new AVLNode<E>(coll); | |
| 88 | size = coll.size(); | |
| 89 | } | |
| 90 | } | |
| 91 | ||
| 92 | //----------------------------------------------------------------------- | |
| 93 | /** | |
| 94 | * Gets the element at the specified index. | |
| 95 | * | |
| 96 | * @param index the index to retrieve | |
| 97 | * @return the element at the specified index | |
| 98 | */ | |
| 99 | @Override | |
| 100 | public E get(final int index) { | |
| 101 |
2
1. get : Replaced integer subtraction with addition → NO_COVERAGE 2. get : removed call to org/apache/commons/collections4/list/TreeList::checkInterval → NO_COVERAGE |
checkInterval(index, 0, size() - 1); |
| 102 |
1
1. get : mutated return of Object value for org/apache/commons/collections4/list/TreeList::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return root.get(index).getValue(); |
| 103 | } | |
| 104 | ||
| 105 | /** | |
| 106 | * Gets the current size of the list. | |
| 107 | * | |
| 108 | * @return the current size | |
| 109 | */ | |
| 110 | @Override | |
| 111 | public int size() { | |
| 112 |
1
1. size : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return size; |
| 113 | } | |
| 114 | ||
| 115 | /** | |
| 116 | * Gets an iterator over the list. | |
| 117 | * | |
| 118 | * @return an iterator over the list | |
| 119 | */ | |
| 120 | @Override | |
| 121 | public Iterator<E> iterator() { | |
| 122 | // override to go 75% faster | |
| 123 |
1
1. iterator : mutated return of Object value for org/apache/commons/collections4/list/TreeList::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return listIterator(0); |
| 124 | } | |
| 125 | ||
| 126 | /** | |
| 127 | * Gets a ListIterator over the list. | |
| 128 | * | |
| 129 | * @return the new iterator | |
| 130 | */ | |
| 131 | @Override | |
| 132 | public ListIterator<E> listIterator() { | |
| 133 | // override to go 75% faster | |
| 134 |
1
1. listIterator : mutated return of Object value for org/apache/commons/collections4/list/TreeList::listIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return listIterator(0); |
| 135 | } | |
| 136 | ||
| 137 | /** | |
| 138 | * Gets a ListIterator over the list. | |
| 139 | * | |
| 140 | * @param fromIndex the index to start from | |
| 141 | * @return the new iterator | |
| 142 | */ | |
| 143 | @Override | |
| 144 | public ListIterator<E> listIterator(final int fromIndex) { | |
| 145 | // override to go 75% faster | |
| 146 | // cannot use EmptyIterator as iterator.add() must work | |
| 147 |
1
1. listIterator : removed call to org/apache/commons/collections4/list/TreeList::checkInterval → NO_COVERAGE |
checkInterval(fromIndex, 0, size()); |
| 148 |
1
1. listIterator : mutated return of Object value for org/apache/commons/collections4/list/TreeList::listIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new TreeListIterator<E>(this, fromIndex); |
| 149 | } | |
| 150 | ||
| 151 | /** | |
| 152 | * Searches for the index of an object in the list. | |
| 153 | * | |
| 154 | * @param object the object to search | |
| 155 | * @return the index of the object, -1 if not found | |
| 156 | */ | |
| 157 | @Override | |
| 158 | public int indexOf(final Object object) { | |
| 159 | // override to go 75% faster | |
| 160 |
1
1. indexOf : negated conditional → NO_COVERAGE |
if (root == null) { |
| 161 |
1
1. indexOf : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return -1; |
| 162 | } | |
| 163 |
1
1. indexOf : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return root.indexOf(object, root.relativePosition); |
| 164 | } | |
| 165 | ||
| 166 | /** | |
| 167 | * Searches for the presence of an object in the list. | |
| 168 | * | |
| 169 | * @param object the object to check | |
| 170 | * @return true if the object is found | |
| 171 | */ | |
| 172 | @Override | |
| 173 | public boolean contains(final Object object) { | |
| 174 |
3
1. contains : changed conditional boundary → NO_COVERAGE 2. contains : negated conditional → NO_COVERAGE 3. contains : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return indexOf(object) >= 0; |
| 175 | } | |
| 176 | ||
| 177 | /** | |
| 178 | * Converts the list into an array. | |
| 179 | * | |
| 180 | * @return the list as an array | |
| 181 | */ | |
| 182 | @Override | |
| 183 | public Object[] toArray() { | |
| 184 | // override to go 20% faster | |
| 185 | final Object[] array = new Object[size()]; | |
| 186 |
1
1. toArray : negated conditional → NO_COVERAGE |
if (root != null) { |
| 187 |
1
1. toArray : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::toArray → NO_COVERAGE |
root.toArray(array, root.relativePosition); |
| 188 | } | |
| 189 |
1
1. toArray : mutated return of Object value for org/apache/commons/collections4/list/TreeList::toArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return array; |
| 190 | } | |
| 191 | ||
| 192 | //----------------------------------------------------------------------- | |
| 193 | /** | |
| 194 | * Adds a new element to the list. | |
| 195 | * | |
| 196 | * @param index the index to add before | |
| 197 | * @param obj the element to add | |
| 198 | */ | |
| 199 | @Override | |
| 200 | public void add(final int index, final E obj) { | |
| 201 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
modCount++; |
| 202 |
1
1. add : removed call to org/apache/commons/collections4/list/TreeList::checkInterval → NO_COVERAGE |
checkInterval(index, 0, size()); |
| 203 |
1
1. add : negated conditional → NO_COVERAGE |
if (root == null) { |
| 204 | root = new AVLNode<E>(index, obj, null, null); | |
| 205 | } else { | |
| 206 | root = root.insert(index, obj); | |
| 207 | } | |
| 208 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
size++; |
| 209 | } | |
| 210 | ||
| 211 | /** | |
| 212 | * Appends all of the elements in the specified collection to the end of this list, | |
| 213 | * in the order that they are returned by the specified collection's Iterator. | |
| 214 | *
 | |
| 215 | * This method runs in O(n + log m) time, where m is | |
| 216 | * the size of this list and n is the size of {@code c}. | |
| 217 | * | |
| 218 | * @param c the collection to be added to this list | |
| 219 | * @return {@code true} if this list changed as a result of the call | |
| 220 | * @throws NullPointerException {@inheritDoc} | |
| 221 | */ | |
| 222 | @Override | |
| 223 | public boolean addAll(final Collection<? extends E> c) { | |
| 224 |
1
1. addAll : negated conditional → NO_COVERAGE |
if (c.isEmpty()) { |
| 225 |
1
1. addAll : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
| 226 | } | |
| 227 |
1
1. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
modCount += c.size(); |
| 228 | final AVLNode<E> cTree = new AVLNode<E>(c); | |
| 229 |
1
1. addAll : negated conditional → NO_COVERAGE |
root = root == null ? cTree : root.addAll(cTree, size); |
| 230 |
1
1. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
size += c.size(); |
| 231 |
1
1. addAll : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
| 232 | } | |
| 233 | ||
| 234 | /** | |
| 235 | * Sets the element at the specified index. | |
| 236 | * | |
| 237 | * @param index the index to set | |
| 238 | * @param obj the object to store at the specified index | |
| 239 | * @return the previous object at that index | |
| 240 | * @throws IndexOutOfBoundsException if the index is invalid | |
| 241 | */ | |
| 242 | @Override | |
| 243 | public E set(final int index, final E obj) { | |
| 244 |
2
1. set : Replaced integer subtraction with addition → NO_COVERAGE 2. set : removed call to org/apache/commons/collections4/list/TreeList::checkInterval → NO_COVERAGE |
checkInterval(index, 0, size() - 1); |
| 245 | final AVLNode<E> node = root.get(index); | |
| 246 | final E result = node.value; | |
| 247 |
1
1. set : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setValue → NO_COVERAGE |
node.setValue(obj); |
| 248 |
1
1. set : mutated return of Object value for org/apache/commons/collections4/list/TreeList::set to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result; |
| 249 | } | |
| 250 | ||
| 251 | /** | |
| 252 | * Removes the element at the specified index. | |
| 253 | * | |
| 254 | * @param index the index to remove | |
| 255 | * @return the previous object at that index | |
| 256 | */ | |
| 257 | @Override | |
| 258 | public E remove(final int index) { | |
| 259 |
1
1. remove : Replaced integer addition with subtraction → NO_COVERAGE |
modCount++; |
| 260 |
2
1. remove : Replaced integer subtraction with addition → NO_COVERAGE 2. remove : removed call to org/apache/commons/collections4/list/TreeList::checkInterval → NO_COVERAGE |
checkInterval(index, 0, size() - 1); |
| 261 | final E result = get(index); | |
| 262 | root = root.remove(index); | |
| 263 |
1
1. remove : Replaced integer subtraction with addition → NO_COVERAGE |
size--; |
| 264 |
1
1. remove : mutated return of Object value for org/apache/commons/collections4/list/TreeList::remove to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result; |
| 265 | } | |
| 266 | ||
| 267 | /** | |
| 268 | * Clears the list, removing all entries. | |
| 269 | */ | |
| 270 | @Override | |
| 271 | public void clear() { | |
| 272 |
1
1. clear : Replaced integer addition with subtraction → NO_COVERAGE |
modCount++; |
| 273 | root = null; | |
| 274 | size = 0; | |
| 275 | } | |
| 276 | ||
| 277 | //----------------------------------------------------------------------- | |
| 278 | /** | |
| 279 | * Checks whether the index is valid. | |
| 280 | * | |
| 281 | * @param index the index to check | |
| 282 | * @param startIndex the first allowed index | |
| 283 | * @param endIndex the last allowed index | |
| 284 | * @throws IndexOutOfBoundsException if the index is invalid | |
| 285 | */ | |
| 286 | private void checkInterval(final int index, final int startIndex, final int endIndex) { | |
| 287 |
4
1. checkInterval : changed conditional boundary → NO_COVERAGE 2. checkInterval : changed conditional boundary → NO_COVERAGE 3. checkInterval : negated conditional → NO_COVERAGE 4. checkInterval : negated conditional → NO_COVERAGE |
if (index < startIndex || index > endIndex) { |
| 288 | throw new IndexOutOfBoundsException("Invalid index:" + index + ", size=" + size()); | |
| 289 | } | |
| 290 | } | |
| 291 | ||
| 292 | //----------------------------------------------------------------------- | |
| 293 | /** | |
| 294 | * Implements an AVLNode which keeps the offset updated. | |
| 295 | *
 | |
| 296 | * This node contains the real work. | |
| 297 | * TreeList is just there to implement {@link java.util.List}. | |
| 298 | * The nodes don't know the index of the object they are holding. They | |
| 299 | * do know however their position relative to their parent node. | |
| 300 | * This allows to calculate the index of a node while traversing the tree. | |
| 301 | *
 | |
| 302 | * The Faedelung calculation stores a flag for both the left and right child | |
| 303 | * to indicate if they are a child (false) or a link as in linked list (true). | |
| 304 | */ | |
| 305 | static class AVLNode<E> { | |
| 306 | /** The left child node or the predecessor if {@link #leftIsPrevious}.*/ | |
| 307 | private AVLNode<E> left; | |
| 308 | /** Flag indicating that left reference is not a subtree but the predecessor. */ | |
| 309 | private boolean leftIsPrevious; | |
| 310 | /** The right child node or the successor if {@link #rightIsNext}. */ | |
| 311 | private AVLNode<E> right; | |
| 312 | /** Flag indicating that right reference is not a subtree but the successor. */ | |
| 313 | private boolean rightIsNext; | |
| 314 | /** How many levels of left/right are below this one. */ | |
| 315 | private int height; | |
| 316 | /** The relative position, root holds absolute position. */ | |
| 317 | private int relativePosition; | |
| 318 | /** The stored element. */ | |
| 319 | private E value; | |
| 320 | ||
| 321 | /** | |
| 322 | * Constructs a new node with a relative position. | |
| 323 | * | |
| 324 | * @param relativePosition the relative position of the node | |
| 325 | * @param obj the value for the node | |
| 326 | * @param rightFollower the node with the value following this one | |
| 327 | * @param leftFollower the node with the value leading this one | |
| 328 | */ | |
| 329 | private AVLNode(final int relativePosition, final E obj, | |
| 330 | final AVLNode<E> rightFollower, final AVLNode<E> leftFollower) { | |
| 331 | this.relativePosition = relativePosition; | |
| 332 | value = obj; | |
| 333 | rightIsNext = true; | |
| 334 | leftIsPrevious = true; | |
| 335 | right = rightFollower; | |
| 336 | left = leftFollower; | |
| 337 | } | |
| 338 | ||
| 339 | /** | |
| 340 | * Constructs a new AVL tree from a collection. | |
| 341 | *
 | |
| 342 | * The collection must be nonempty. | |
| 343 | * | |
| 344 | * @param coll a nonempty collection | |
| 345 | */ | |
| 346 | private AVLNode(final Collection<? extends E> coll) { | |
| 347 |
1
1. |
this(coll.iterator(), 0, coll.size() - 1, 0, null, null); |
| 348 | } | |
| 349 | ||
| 350 | /** | |
| 351 | * Constructs a new AVL tree from a collection. | |
| 352 | *
 | |
| 353 | * This is a recursive helper for {@link #AVLNode(Collection)}. A call | |
| 354 | * to this method will construct the subtree for elements {@code start} | |
| 355 | * through {@code end} of the collection, assuming the iterator | |
| 356 | * {@code e} already points at element {@code start}. | |
| 357 | * | |
| 358 | * @param iterator an iterator over the collection, which should already point | |
| 359 | * to the element at index {@code start} within the collection | |
| 360 | * @param start the index of the first element in the collection that | |
| 361 | * should be in this subtree | |
| 362 | * @param end the index of the last element in the collection that | |
| 363 | * should be in this subtree | |
| 364 | * @param absolutePositionOfParent absolute position of this node's | |
| 365 | * parent, or 0 if this node is the root | |
| 366 | * @param prev the {@code AVLNode} corresponding to element (start - 1) | |
| 367 | * of the collection, or null if start is 0 | |
| 368 | * @param next the {@code AVLNode} corresponding to element (end + 1) | |
| 369 | * of the collection, or null if end is the last element of the collection | |
| 370 | */ | |
| 371 | private AVLNode(final Iterator<? extends E> iterator, final int start, final int end, | |
| 372 | final int absolutePositionOfParent, final AVLNode<E> prev, final AVLNode<E> next) { | |
| 373 |
3
1. 2. 3. |
final int mid = start + (end - start) / 2; |
| 374 |
2
1. 2. |
if (start < mid) { |
| 375 |
1
1. |
left = new AVLNode<E>(iterator, start, mid - 1, mid, prev, this); |
| 376 | } else { | |
| 377 | leftIsPrevious = true; | |
| 378 | left = prev; | |
| 379 | } | |
| 380 | value = iterator.next(); | |
| 381 |
1
1. |
relativePosition = mid - absolutePositionOfParent; |
| 382 |
2
1. 2. |
if (mid < end) { |
| 383 |
1
1. |
right = new AVLNode<E>(iterator, mid + 1, end, mid, this, next); |
| 384 | } else { | |
| 385 | rightIsNext = true; | |
| 386 | right = next; | |
| 387 | } | |
| 388 |
1
1. |
recalcHeight(); |
| 389 | } | |
| 390 | ||
| 391 | /** | |
| 392 | * Gets the value. | |
| 393 | * | |
| 394 | * @return the value of this node | |
| 395 | */ | |
| 396 | E getValue() { | |
| 397 |
1
1. getValue : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::getValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return value; |
| 398 | } | |
| 399 | ||
| 400 | /** | |
| 401 | * Sets the value. | |
| 402 | * | |
| 403 | * @param obj the value to store | |
| 404 | */ | |
| 405 | void setValue(final E obj) { | |
| 406 | this.value = obj; | |
| 407 | } | |
| 408 | ||
| 409 | /** | |
| 410 | * Locate the element with the given index relative to the | |
| 411 | * offset of the parent of this node. | |
| 412 | */ | |
| 413 | AVLNode<E> get(final int index) { | |
| 414 |
1
1. get : Replaced integer subtraction with addition → NO_COVERAGE |
final int indexRelativeToMe = index - relativePosition; |
| 415 | ||
| 416 |
1
1. get : negated conditional → NO_COVERAGE |
if (indexRelativeToMe == 0) { |
| 417 |
1
1. get : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return this; |
| 418 | } | |
| 419 | ||
| 420 |
2
1. get : changed conditional boundary → NO_COVERAGE 2. get : negated conditional → NO_COVERAGE |
final AVLNode<E> nextNode = indexRelativeToMe < 0 ? getLeftSubTree() : getRightSubTree(); |
| 421 |
1
1. get : negated conditional → NO_COVERAGE |
if (nextNode == null) { |
| 422 |
1
1. get : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
| 423 | } | |
| 424 |
1
1. get : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::get to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return nextNode.get(indexRelativeToMe); |
| 425 | } | |
| 426 | ||
| 427 | /** | |
| 428 | * Locate the index that contains the specified object. | |
| 429 | */ | |
| 430 | int indexOf(final Object object, final int index) { | |
| 431 |
1
1. indexOf : negated conditional → NO_COVERAGE |
if (getLeftSubTree() != null) { |
| 432 |
1
1. indexOf : Replaced integer addition with subtraction → NO_COVERAGE |
final int result = left.indexOf(object, index + left.relativePosition); |
| 433 |
1
1. indexOf : negated conditional → NO_COVERAGE |
if (result != -1) { |
| 434 |
1
1. indexOf : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return result; |
| 435 | } | |
| 436 | } | |
| 437 |
3
1. indexOf : negated conditional → NO_COVERAGE 2. indexOf : negated conditional → NO_COVERAGE 3. indexOf : negated conditional → NO_COVERAGE |
if (value == null ? value == object : value.equals(object)) { |
| 438 |
1
1. indexOf : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return index; |
| 439 | } | |
| 440 |
1
1. indexOf : negated conditional → NO_COVERAGE |
if (getRightSubTree() != null) { |
| 441 |
2
1. indexOf : Replaced integer addition with subtraction → NO_COVERAGE 2. indexOf : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return right.indexOf(object, index + right.relativePosition); |
| 442 | } | |
| 443 |
1
1. indexOf : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return -1; |
| 444 | } | |
| 445 | ||
| 446 | /** | |
| 447 | * Stores the node and its children into the array specified. | |
| 448 | * | |
| 449 | * @param array the array to be filled | |
| 450 | * @param index the index of this node | |
| 451 | */ | |
| 452 | void toArray(final Object[] array, final int index) { | |
| 453 | array[index] = value; | |
| 454 |
1
1. toArray : negated conditional → NO_COVERAGE |
if (getLeftSubTree() != null) { |
| 455 |
2
1. toArray : Replaced integer addition with subtraction → NO_COVERAGE 2. toArray : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::toArray → NO_COVERAGE |
left.toArray(array, index + left.relativePosition); |
| 456 | } | |
| 457 |
1
1. toArray : negated conditional → NO_COVERAGE |
if (getRightSubTree() != null) { |
| 458 |
2
1. toArray : Replaced integer addition with subtraction → NO_COVERAGE 2. toArray : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::toArray → NO_COVERAGE |
right.toArray(array, index + right.relativePosition); |
| 459 | } | |
| 460 | } | |
| 461 | ||
| 462 | /** | |
| 463 | * Gets the next node in the list after this one. | |
| 464 | * | |
| 465 | * @return the next node | |
| 466 | */ | |
| 467 | AVLNode<E> next() { | |
| 468 |
2
1. next : negated conditional → NO_COVERAGE 2. next : negated conditional → NO_COVERAGE |
if (rightIsNext || right == null) { |
| 469 |
1
1. next : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::next to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return right; |
| 470 | } | |
| 471 |
1
1. next : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::next to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return right.min(); |
| 472 | } | |
| 473 | ||
| 474 | /** | |
| 475 | * Gets the node in the list before this one. | |
| 476 | * | |
| 477 | * @return the previous node | |
| 478 | */ | |
| 479 | AVLNode<E> previous() { | |
| 480 |
2
1. previous : negated conditional → NO_COVERAGE 2. previous : negated conditional → NO_COVERAGE |
if (leftIsPrevious || left == null) { |
| 481 |
1
1. previous : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::previous to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return left; |
| 482 | } | |
| 483 |
1
1. previous : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::previous to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return left.max(); |
| 484 | } | |
| 485 | ||
| 486 | /** | |
| 487 | * Inserts a node at the position index. | |
| 488 | * | |
| 489 | * @param index is the index of the position relative to the position of | |
| 490 | * the parent node. | |
| 491 | * @param obj is the object to be stored in the position. | |
| 492 | */ | |
| 493 | AVLNode<E> insert(final int index, final E obj) { | |
| 494 |
1
1. insert : Replaced integer subtraction with addition → NO_COVERAGE |
final int indexRelativeToMe = index - relativePosition; |
| 495 | ||
| 496 |
2
1. insert : changed conditional boundary → NO_COVERAGE 2. insert : negated conditional → NO_COVERAGE |
if (indexRelativeToMe <= 0) { |
| 497 |
1
1. insert : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::insert to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return insertOnLeft(indexRelativeToMe, obj); |
| 498 | } | |
| 499 |
1
1. insert : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::insert to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return insertOnRight(indexRelativeToMe, obj); |
| 500 | } | |
| 501 | ||
| 502 | private AVLNode<E> insertOnLeft(final int indexRelativeToMe, final E obj) { | |
| 503 |
1
1. insertOnLeft : negated conditional → NO_COVERAGE |
if (getLeftSubTree() == null) { |
| 504 |
1
1. insertOnLeft : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
setLeft(new AVLNode<E>(-1, obj, this, left), null); |
| 505 | } else { | |
| 506 |
1
1. insertOnLeft : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
setLeft(left.insert(indexRelativeToMe, obj), null); |
| 507 | } | |
| 508 | ||
| 509 |
2
1. insertOnLeft : changed conditional boundary → NO_COVERAGE 2. insertOnLeft : negated conditional → NO_COVERAGE |
if (relativePosition >= 0) { |
| 510 |
1
1. insertOnLeft : Replaced integer addition with subtraction → NO_COVERAGE |
relativePosition++; |
| 511 | } | |
| 512 | final AVLNode<E> ret = balance(); | |
| 513 |
1
1. insertOnLeft : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 514 |
1
1. insertOnLeft : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::insertOnLeft to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ret; |
| 515 | } | |
| 516 | ||
| 517 | private AVLNode<E> insertOnRight(final int indexRelativeToMe, final E obj) { | |
| 518 |
1
1. insertOnRight : negated conditional → NO_COVERAGE |
if (getRightSubTree() == null) { |
| 519 |
1
1. insertOnRight : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
setRight(new AVLNode<E>(+1, obj, right, this), null); |
| 520 | } else { | |
| 521 |
1
1. insertOnRight : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
setRight(right.insert(indexRelativeToMe, obj), null); |
| 522 | } | |
| 523 |
2
1. insertOnRight : changed conditional boundary → NO_COVERAGE 2. insertOnRight : negated conditional → NO_COVERAGE |
if (relativePosition < 0) { |
| 524 |
1
1. insertOnRight : Replaced integer subtraction with addition → NO_COVERAGE |
relativePosition--; |
| 525 | } | |
| 526 | final AVLNode<E> ret = balance(); | |
| 527 |
1
1. insertOnRight : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 528 |
1
1. insertOnRight : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::insertOnRight to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ret; |
| 529 | } | |
| 530 | ||
| 531 | //----------------------------------------------------------------------- | |
| 532 | /** | |
| 533 | * Gets the left node, returning null if its a faedelung. | |
| 534 | */ | |
| 535 | private AVLNode<E> getLeftSubTree() { | |
| 536 |
2
1. getLeftSubTree : negated conditional → NO_COVERAGE 2. getLeftSubTree : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::getLeftSubTree to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return leftIsPrevious ? null : left; |
| 537 | } | |
| 538 | ||
| 539 | /** | |
| 540 | * Gets the right node, returning null if its a faedelung. | |
| 541 | */ | |
| 542 | private AVLNode<E> getRightSubTree() { | |
| 543 |
2
1. getRightSubTree : negated conditional → NO_COVERAGE 2. getRightSubTree : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::getRightSubTree to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return rightIsNext ? null : right; |
| 544 | } | |
| 545 | ||
| 546 | /** | |
| 547 | * Gets the rightmost child of this node. | |
| 548 | * | |
| 549 | * @return the rightmost child (greatest index) | |
| 550 | */ | |
| 551 | private AVLNode<E> max() { | |
| 552 |
2
1. max : negated conditional → NO_COVERAGE 2. max : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::max to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return getRightSubTree() == null ? this : right.max(); |
| 553 | } | |
| 554 | ||
| 555 | /** | |
| 556 | * Gets the leftmost child of this node. | |
| 557 | * | |
| 558 | * @return the leftmost child (smallest index) | |
| 559 | */ | |
| 560 | private AVLNode<E> min() { | |
| 561 |
2
1. min : negated conditional → NO_COVERAGE 2. min : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::min to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return getLeftSubTree() == null ? this : left.min(); |
| 562 | } | |
| 563 | ||
| 564 | /** | |
| 565 | * Removes the node at a given position. | |
| 566 | * | |
| 567 | * @param index is the index of the element to be removed relative to the position of | |
| 568 | * the parent node of the current node. | |
| 569 | */ | |
| 570 | AVLNode<E> remove(final int index) { | |
| 571 |
1
1. remove : Replaced integer subtraction with addition → NO_COVERAGE |
final int indexRelativeToMe = index - relativePosition; |
| 572 | ||
| 573 |
1
1. remove : negated conditional → NO_COVERAGE |
if (indexRelativeToMe == 0) { |
| 574 |
1
1. remove : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::remove to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return removeSelf(); |
| 575 | } | |
| 576 |
2
1. remove : changed conditional boundary → NO_COVERAGE 2. remove : negated conditional → NO_COVERAGE |
if (indexRelativeToMe > 0) { |
| 577 |
1
1. remove : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
setRight(right.remove(indexRelativeToMe), right.right); |
| 578 |
2
1. remove : changed conditional boundary → NO_COVERAGE 2. remove : negated conditional → NO_COVERAGE |
if (relativePosition < 0) { |
| 579 |
1
1. remove : Replaced integer addition with subtraction → NO_COVERAGE |
relativePosition++; |
| 580 | } | |
| 581 | } else { | |
| 582 |
1
1. remove : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
setLeft(left.remove(indexRelativeToMe), left.left); |
| 583 |
2
1. remove : changed conditional boundary → NO_COVERAGE 2. remove : negated conditional → NO_COVERAGE |
if (relativePosition > 0) { |
| 584 |
1
1. remove : Replaced integer subtraction with addition → NO_COVERAGE |
relativePosition--; |
| 585 | } | |
| 586 | } | |
| 587 |
1
1. remove : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 588 |
1
1. remove : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::remove to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return balance(); |
| 589 | } | |
| 590 | ||
| 591 | private AVLNode<E> removeMax() { | |
| 592 |
1
1. removeMax : negated conditional → NO_COVERAGE |
if (getRightSubTree() == null) { |
| 593 |
1
1. removeMax : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeMax to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return removeSelf(); |
| 594 | } | |
| 595 |
1
1. removeMax : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
setRight(right.removeMax(), right.right); |
| 596 |
2
1. removeMax : changed conditional boundary → NO_COVERAGE 2. removeMax : negated conditional → NO_COVERAGE |
if (relativePosition < 0) { |
| 597 |
1
1. removeMax : Replaced integer addition with subtraction → NO_COVERAGE |
relativePosition++; |
| 598 | } | |
| 599 |
1
1. removeMax : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 600 |
1
1. removeMax : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeMax to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return balance(); |
| 601 | } | |
| 602 | ||
| 603 | private AVLNode<E> removeMin() { | |
| 604 |
1
1. removeMin : negated conditional → NO_COVERAGE |
if (getLeftSubTree() == null) { |
| 605 |
1
1. removeMin : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeMin to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return removeSelf(); |
| 606 | } | |
| 607 |
1
1. removeMin : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
setLeft(left.removeMin(), left.left); |
| 608 |
2
1. removeMin : changed conditional boundary → NO_COVERAGE 2. removeMin : negated conditional → NO_COVERAGE |
if (relativePosition > 0) { |
| 609 |
1
1. removeMin : Replaced integer subtraction with addition → NO_COVERAGE |
relativePosition--; |
| 610 | } | |
| 611 |
1
1. removeMin : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 612 |
1
1. removeMin : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeMin to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return balance(); |
| 613 | } | |
| 614 | ||
| 615 | /** | |
| 616 | * Removes this node from the tree. | |
| 617 | * | |
| 618 | * @return the node that replaces this one in the parent | |
| 619 | */ | |
| 620 | private AVLNode<E> removeSelf() { | |
| 621 |
2
1. removeSelf : negated conditional → NO_COVERAGE 2. removeSelf : negated conditional → NO_COVERAGE |
if (getRightSubTree() == null && getLeftSubTree() == null) { |
| 622 |
1
1. removeSelf : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeSelf to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
| 623 | } | |
| 624 |
1
1. removeSelf : negated conditional → NO_COVERAGE |
if (getRightSubTree() == null) { |
| 625 |
2
1. removeSelf : changed conditional boundary → NO_COVERAGE 2. removeSelf : negated conditional → NO_COVERAGE |
if (relativePosition > 0) { |
| 626 |
4
1. removeSelf : changed conditional boundary → NO_COVERAGE 2. removeSelf : Replaced integer addition with subtraction → NO_COVERAGE 3. removeSelf : Replaced integer addition with subtraction → NO_COVERAGE 4. removeSelf : negated conditional → NO_COVERAGE |
left.relativePosition += relativePosition + (relativePosition > 0 ? 0 : 1); |
| 627 | } | |
| 628 |
1
1. removeSelf : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
left.max().setRight(null, right); |
| 629 |
1
1. removeSelf : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeSelf to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return left; |
| 630 | } | |
| 631 |
1
1. removeSelf : negated conditional → NO_COVERAGE |
if (getLeftSubTree() == null) { |
| 632 |
4
1. removeSelf : changed conditional boundary → NO_COVERAGE 2. removeSelf : Replaced integer subtraction with addition → NO_COVERAGE 3. removeSelf : Replaced integer addition with subtraction → NO_COVERAGE 4. removeSelf : negated conditional → NO_COVERAGE |
right.relativePosition += relativePosition - (relativePosition < 0 ? 0 : 1); |
| 633 |
1
1. removeSelf : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
right.min().setLeft(null, left); |
| 634 |
1
1. removeSelf : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeSelf to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return right; |
| 635 | } | |
| 636 | ||
| 637 |
2
1. removeSelf : changed conditional boundary → NO_COVERAGE 2. removeSelf : negated conditional → NO_COVERAGE |
if (heightRightMinusLeft() > 0) { |
| 638 | // more on the right, so delete from the right | |
| 639 | final AVLNode<E> rightMin = right.min(); | |
| 640 | value = rightMin.value; | |
| 641 |
1
1. removeSelf : negated conditional → NO_COVERAGE |
if (leftIsPrevious) { |
| 642 | left = rightMin.left; | |
| 643 | } | |
| 644 | right = right.removeMin(); | |
| 645 |
2
1. removeSelf : changed conditional boundary → NO_COVERAGE 2. removeSelf : negated conditional → NO_COVERAGE |
if (relativePosition < 0) { |
| 646 |
1
1. removeSelf : Replaced integer addition with subtraction → NO_COVERAGE |
relativePosition++; |
| 647 | } | |
| 648 | } else { | |
| 649 | // more on the left or equal, so delete from the left | |
| 650 | final AVLNode<E> leftMax = left.max(); | |
| 651 | value = leftMax.value; | |
| 652 |
1
1. removeSelf : negated conditional → NO_COVERAGE |
if (rightIsNext) { |
| 653 | right = leftMax.right; | |
| 654 | } | |
| 655 | final AVLNode<E> leftPrevious = left.left; | |
| 656 | left = left.removeMax(); | |
| 657 |
1
1. removeSelf : negated conditional → NO_COVERAGE |
if (left == null) { |
| 658 | // special case where left that was deleted was a double link | |
| 659 | // only occurs when height difference is equal | |
| 660 | left = leftPrevious; | |
| 661 | leftIsPrevious = true; | |
| 662 | } | |
| 663 |
2
1. removeSelf : changed conditional boundary → NO_COVERAGE 2. removeSelf : negated conditional → NO_COVERAGE |
if (relativePosition > 0) { |
| 664 |
1
1. removeSelf : Replaced integer subtraction with addition → NO_COVERAGE |
relativePosition--; |
| 665 | } | |
| 666 | } | |
| 667 |
1
1. removeSelf : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 668 |
1
1. removeSelf : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::removeSelf to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return this; |
| 669 | } | |
| 670 | ||
| 671 | //----------------------------------------------------------------------- | |
| 672 | /** | |
| 673 | * Balances according to the AVL algorithm. | |
| 674 | */ | |
| 675 | private AVLNode<E> balance() { | |
| 676 | switch (heightRightMinusLeft()) { | |
| 677 | case 1 : | |
| 678 | case 0 : | |
| 679 | case -1 : | |
| 680 |
1
1. balance : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::balance to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return this; |
| 681 | case -2 : | |
| 682 |
2
1. balance : changed conditional boundary → NO_COVERAGE 2. balance : negated conditional → NO_COVERAGE |
if (left.heightRightMinusLeft() > 0) { |
| 683 |
1
1. balance : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
setLeft(left.rotateLeft(), null); |
| 684 | } | |
| 685 |
1
1. balance : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::balance to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return rotateRight(); |
| 686 | case 2 : | |
| 687 |
2
1. balance : changed conditional boundary → NO_COVERAGE 2. balance : negated conditional → NO_COVERAGE |
if (right.heightRightMinusLeft() < 0) { |
| 688 |
1
1. balance : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
setRight(right.rotateRight(), null); |
| 689 | } | |
| 690 |
1
1. balance : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::balance to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return rotateLeft(); |
| 691 | default : | |
| 692 | throw new RuntimeException("tree inconsistent!"); | |
| 693 | } | |
| 694 | } | |
| 695 | ||
| 696 | /** | |
| 697 | * Gets the relative position. | |
| 698 | */ | |
| 699 | private int getOffset(final AVLNode<E> node) { | |
| 700 |
1
1. getOffset : negated conditional → NO_COVERAGE |
if (node == null) { |
| 701 |
1
1. getOffset : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 0; |
| 702 | } | |
| 703 |
1
1. getOffset : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return node.relativePosition; |
| 704 | } | |
| 705 | ||
| 706 | /** | |
| 707 | * Sets the relative position. | |
| 708 | */ | |
| 709 | private int setOffset(final AVLNode<E> node, final int newOffest) { | |
| 710 |
1
1. setOffset : negated conditional → NO_COVERAGE |
if (node == null) { |
| 711 |
1
1. setOffset : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 0; |
| 712 | } | |
| 713 | final int oldOffset = getOffset(node); | |
| 714 | node.relativePosition = newOffest; | |
| 715 |
1
1. setOffset : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return oldOffset; |
| 716 | } | |
| 717 | ||
| 718 | /** | |
| 719 | * Sets the height by calculation. | |
| 720 | */ | |
| 721 | private void recalcHeight() { | |
| 722 |
1
1. recalcHeight : Replaced integer addition with subtraction → NO_COVERAGE |
height = Math.max( |
| 723 |
1
1. recalcHeight : negated conditional → NO_COVERAGE |
getLeftSubTree() == null ? -1 : getLeftSubTree().height, |
| 724 |
1
1. recalcHeight : negated conditional → NO_COVERAGE |
getRightSubTree() == null ? -1 : getRightSubTree().height) + 1; |
| 725 | } | |
| 726 | ||
| 727 | /** | |
| 728 | * Returns the height of the node or -1 if the node is null. | |
| 729 | */ | |
| 730 | private int getHeight(final AVLNode<E> node) { | |
| 731 |
2
1. getHeight : negated conditional → NO_COVERAGE 2. getHeight : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return node == null ? -1 : node.height; |
| 732 | } | |
| 733 | ||
| 734 | /** | |
| 735 | * Returns the height difference right - left | |
| 736 | */ | |
| 737 | private int heightRightMinusLeft() { | |
| 738 |
2
1. heightRightMinusLeft : Replaced integer subtraction with addition → NO_COVERAGE 2. heightRightMinusLeft : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return getHeight(getRightSubTree()) - getHeight(getLeftSubTree()); |
| 739 | } | |
| 740 | ||
| 741 | private AVLNode<E> rotateLeft() { | |
| 742 | final AVLNode<E> newTop = right; // can't be faedelung! | |
| 743 | final AVLNode<E> movedNode = getRightSubTree().getLeftSubTree(); | |
| 744 | ||
| 745 |
1
1. rotateLeft : Replaced integer addition with subtraction → NO_COVERAGE |
final int newTopPosition = relativePosition + getOffset(newTop); |
| 746 |
1
1. rotateLeft : removed negation → NO_COVERAGE |
final int myNewPosition = -newTop.relativePosition; |
| 747 |
1
1. rotateLeft : Replaced integer addition with subtraction → NO_COVERAGE |
final int movedPosition = getOffset(newTop) + getOffset(movedNode); |
| 748 | ||
| 749 |
1
1. rotateLeft : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
setRight(movedNode, newTop); |
| 750 |
1
1. rotateLeft : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
newTop.setLeft(this, null); |
| 751 | ||
| 752 | setOffset(newTop, newTopPosition); | |
| 753 | setOffset(this, myNewPosition); | |
| 754 | setOffset(movedNode, movedPosition); | |
| 755 |
1
1. rotateLeft : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::rotateLeft to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return newTop; |
| 756 | } | |
| 757 | ||
| 758 | private AVLNode<E> rotateRight() { | |
| 759 | final AVLNode<E> newTop = left; // can't be faedelung | |
| 760 | final AVLNode<E> movedNode = getLeftSubTree().getRightSubTree(); | |
| 761 | ||
| 762 |
1
1. rotateRight : Replaced integer addition with subtraction → NO_COVERAGE |
final int newTopPosition = relativePosition + getOffset(newTop); |
| 763 |
1
1. rotateRight : removed negation → NO_COVERAGE |
final int myNewPosition = -newTop.relativePosition; |
| 764 |
1
1. rotateRight : Replaced integer addition with subtraction → NO_COVERAGE |
final int movedPosition = getOffset(newTop) + getOffset(movedNode); |
| 765 | ||
| 766 |
1
1. rotateRight : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
setLeft(movedNode, newTop); |
| 767 |
1
1. rotateRight : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
newTop.setRight(this, null); |
| 768 | ||
| 769 | setOffset(newTop, newTopPosition); | |
| 770 | setOffset(this, myNewPosition); | |
| 771 | setOffset(movedNode, movedPosition); | |
| 772 |
1
1. rotateRight : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::rotateRight to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return newTop; |
| 773 | } | |
| 774 | ||
| 775 | /** | |
| 776 | * Sets the left field to the node, or the previous node if that is null | |
| 777 | * | |
| 778 | * @param node the new left subtree node | |
| 779 | * @param previous the previous node in the linked list | |
| 780 | */ | |
| 781 | private void setLeft(final AVLNode<E> node, final AVLNode<E> previous) { | |
| 782 |
1
1. setLeft : negated conditional → NO_COVERAGE |
leftIsPrevious = node == null; |
| 783 |
1
1. setLeft : negated conditional → NO_COVERAGE |
left = leftIsPrevious ? previous : node; |
| 784 |
1
1. setLeft : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 785 | } | |
| 786 | ||
| 787 | /** | |
| 788 | * Sets the right field to the node, or the next node if that is null | |
| 789 | * | |
| 790 | * @param node the new left subtree node | |
| 791 | * @param next the next node in the linked list | |
| 792 | */ | |
| 793 | private void setRight(final AVLNode<E> node, final AVLNode<E> next) { | |
| 794 |
1
1. setRight : negated conditional → NO_COVERAGE |
rightIsNext = node == null; |
| 795 |
1
1. setRight : negated conditional → NO_COVERAGE |
right = rightIsNext ? next : node; |
| 796 |
1
1. setRight : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::recalcHeight → NO_COVERAGE |
recalcHeight(); |
| 797 | } | |
| 798 | ||
| 799 | /** | |
| 800 | * Appends the elements of another tree list to this tree list by efficiently | |
| 801 | * merging the two AVL trees. This operation is destructive to both trees and | |
| 802 | * runs in O(log(m + n)) time. | |
| 803 | * | |
| 804 | * @param otherTree | |
| 805 | * the root of the AVL tree to merge with this one | |
| 806 | * @param currentSize | |
| 807 | * the number of elements in this AVL tree | |
| 808 | * @return the root of the new, merged AVL tree | |
| 809 | */ | |
| 810 | private AVLNode<E> addAll(AVLNode<E> otherTree, final int currentSize) { | |
| 811 | final AVLNode<E> maxNode = max(); | |
| 812 | final AVLNode<E> otherTreeMin = otherTree.min(); | |
| 813 | ||
| 814 | // We need to efficiently merge the two AVL trees while keeping them | |
| 815 | // balanced (or nearly balanced). To do this, we take the shorter | |
| 816 | // tree and combine it with a similar-height subtree of the taller | |
| 817 | // tree. There are two symmetric cases: | |
| 818 | // * this tree is taller, or | |
| 819 | // * otherTree is taller. | |
| 820 |
2
1. addAll : changed conditional boundary → NO_COVERAGE 2. addAll : negated conditional → NO_COVERAGE |
if (otherTree.height > height) { |
| 821 | // CASE 1: The other tree is taller than this one. We will thus | |
| 822 | // merge this tree into otherTree. | |
| 823 | ||
| 824 | // STEP 1: Remove the maximum element from this tree. | |
| 825 | final AVLNode<E> leftSubTree = removeMax(); | |
| 826 | ||
| 827 | // STEP 2: Navigate left from the root of otherTree until we | |
| 828 | // find a subtree, s, that is no taller than me. (While we are | |
| 829 | // navigating left, we store the nodes we encounter in a stack | |
| 830 | // so that we can re-balance them in step 4.) | |
| 831 | final Deque<AVLNode<E>> sAncestors = new ArrayDeque<AVLNode<E>>(); | |
| 832 | AVLNode<E> s = otherTree; | |
| 833 |
1
1. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
int sAbsolutePosition = s.relativePosition + currentSize; |
| 834 | int sParentAbsolutePosition = 0; | |
| 835 |
3
1. addAll : changed conditional boundary → NO_COVERAGE 2. addAll : negated conditional → NO_COVERAGE 3. addAll : negated conditional → NO_COVERAGE |
while (s != null && s.height > getHeight(leftSubTree)) { |
| 836 | sParentAbsolutePosition = sAbsolutePosition; | |
| 837 |
1
1. addAll : removed call to java/util/Deque::push → NO_COVERAGE |
sAncestors.push(s); |
| 838 | s = s.left; | |
| 839 |
1
1. addAll : negated conditional → NO_COVERAGE |
if (s != null) { |
| 840 |
1
1. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
sAbsolutePosition += s.relativePosition; |
| 841 | } | |
| 842 | } | |
| 843 | ||
| 844 | // STEP 3: Replace s with a newly constructed subtree whose root | |
| 845 | // is maxNode, whose left subtree is leftSubTree, and whose right | |
| 846 | // subtree is s. | |
| 847 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
maxNode.setLeft(leftSubTree, null); |
| 848 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
maxNode.setRight(s, otherTreeMin); |
| 849 |
1
1. addAll : negated conditional → NO_COVERAGE |
if (leftSubTree != null) { |
| 850 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
leftSubTree.max().setRight(null, maxNode); |
| 851 |
2
1. addAll : Replaced integer subtraction with addition → NO_COVERAGE 2. addAll : Replaced integer subtraction with addition → NO_COVERAGE |
leftSubTree.relativePosition -= currentSize - 1; |
| 852 | } | |
| 853 |
1
1. addAll : negated conditional → NO_COVERAGE |
if (s != null) { |
| 854 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
s.min().setLeft(null, maxNode); |
| 855 |
2
1. addAll : Replaced integer subtraction with addition → NO_COVERAGE 2. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
s.relativePosition = sAbsolutePosition - currentSize + 1; |
| 856 | } | |
| 857 |
2
1. addAll : Replaced integer subtraction with addition → NO_COVERAGE 2. addAll : Replaced integer subtraction with addition → NO_COVERAGE |
maxNode.relativePosition = currentSize - 1 - sParentAbsolutePosition; |
| 858 |
1
1. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
otherTree.relativePosition += currentSize; |
| 859 | ||
| 860 | // STEP 4: Re-balance the tree and recalculate the heights of s's ancestors. | |
| 861 | s = maxNode; | |
| 862 |
1
1. addAll : negated conditional → NO_COVERAGE |
while (!sAncestors.isEmpty()) { |
| 863 | final AVLNode<E> sAncestor = sAncestors.pop(); | |
| 864 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
sAncestor.setLeft(s, null); |
| 865 | s = sAncestor.balance(); | |
| 866 | } | |
| 867 |
1
1. addAll : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::addAll to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return s; |
| 868 | } | |
| 869 | otherTree = otherTree.removeMin(); | |
| 870 | ||
| 871 | final Deque<AVLNode<E>> sAncestors = new ArrayDeque<AVLNode<E>>(); | |
| 872 | AVLNode<E> s = this; | |
| 873 | int sAbsolutePosition = s.relativePosition; | |
| 874 | int sParentAbsolutePosition = 0; | |
| 875 |
3
1. addAll : changed conditional boundary → NO_COVERAGE 2. addAll : negated conditional → NO_COVERAGE 3. addAll : negated conditional → NO_COVERAGE |
while (s != null && s.height > getHeight(otherTree)) { |
| 876 | sParentAbsolutePosition = sAbsolutePosition; | |
| 877 |
1
1. addAll : removed call to java/util/Deque::push → NO_COVERAGE |
sAncestors.push(s); |
| 878 | s = s.right; | |
| 879 |
1
1. addAll : negated conditional → NO_COVERAGE |
if (s != null) { |
| 880 |
1
1. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
sAbsolutePosition += s.relativePosition; |
| 881 | } | |
| 882 | } | |
| 883 | ||
| 884 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
otherTreeMin.setRight(otherTree, null); |
| 885 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
otherTreeMin.setLeft(s, maxNode); |
| 886 |
1
1. addAll : negated conditional → NO_COVERAGE |
if (otherTree != null) { |
| 887 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setLeft → NO_COVERAGE |
otherTree.min().setLeft(null, otherTreeMin); |
| 888 |
1
1. addAll : Replaced integer addition with subtraction → NO_COVERAGE |
otherTree.relativePosition++; |
| 889 | } | |
| 890 |
1
1. addAll : negated conditional → NO_COVERAGE |
if (s != null) { |
| 891 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
s.max().setRight(null, otherTreeMin); |
| 892 |
1
1. addAll : Replaced integer subtraction with addition → NO_COVERAGE |
s.relativePosition = sAbsolutePosition - currentSize; |
| 893 | } | |
| 894 |
1
1. addAll : Replaced integer subtraction with addition → NO_COVERAGE |
otherTreeMin.relativePosition = currentSize - sParentAbsolutePosition; |
| 895 | ||
| 896 | s = otherTreeMin; | |
| 897 |
1
1. addAll : negated conditional → NO_COVERAGE |
while (!sAncestors.isEmpty()) { |
| 898 | final AVLNode<E> sAncestor = sAncestors.pop(); | |
| 899 |
1
1. addAll : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setRight → NO_COVERAGE |
sAncestor.setRight(s, null); |
| 900 | s = sAncestor.balance(); | |
| 901 | } | |
| 902 |
1
1. addAll : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::addAll to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return s; |
| 903 | } | |
| 904 | ||
| 905 | // private void checkFaedelung() { | |
| 906 | // AVLNode maxNode = left.max(); | |
| 907 | // if (!maxNode.rightIsFaedelung || maxNode.right != this) { | |
| 908 | // throw new RuntimeException(maxNode + " should right-faedel to " + this); | |
| 909 | // } | |
| 910 | // AVLNode minNode = right.min(); | |
| 911 | // if (!minNode.leftIsFaedelung || minNode.left != this) { | |
| 912 | // throw new RuntimeException(maxNode + " should left-faedel to " + this); | |
| 913 | // } | |
| 914 | // } | |
| 915 | // | |
| 916 | // private int checkTreeDepth() { | |
| 917 | // int hright = (getRightSubTree() == null ? -1 : getRightSubTree().checkTreeDepth()); | |
| 918 | // // System.out.print("checkTreeDepth"); | |
| 919 | // // System.out.print(this); | |
| 920 | // // System.out.print(" left: "); | |
| 921 | // // System.out.print(_left); | |
| 922 | // // System.out.print(" right: "); | |
| 923 | // // System.out.println(_right); | |
| 924 | // | |
| 925 | // int hleft = (left == null ? -1 : left.checkTreeDepth()); | |
| 926 | // if (height != Math.max(hright, hleft) + 1) { | |
| 927 | // throw new RuntimeException( | |
| 928 | // "height should be max" + hleft + "," + hright + " but is " + height); | |
| 929 | // } | |
| 930 | // return height; | |
| 931 | // } | |
| 932 | // | |
| 933 | // private int checkLeftSubNode() { | |
| 934 | // if (getLeftSubTree() == null) { | |
| 935 | // return 0; | |
| 936 | // } | |
| 937 | // int count = 1 + left.checkRightSubNode(); | |
| 938 | // if (left.relativePosition != -count) { | |
| 939 | // throw new RuntimeException(); | |
| 940 | // } | |
| 941 | // return count + left.checkLeftSubNode(); | |
| 942 | // } | |
| 943 | // | |
| 944 | // private int checkRightSubNode() { | |
| 945 | // AVLNode right = getRightSubTree(); | |
| 946 | // if (right == null) { | |
| 947 | // return 0; | |
| 948 | // } | |
| 949 | // int count = 1; | |
| 950 | // count += right.checkLeftSubNode(); | |
| 951 | // if (right.relativePosition != count) { | |
| 952 | // throw new RuntimeException(); | |
| 953 | // } | |
| 954 | // return count + right.checkRightSubNode(); | |
| 955 | // } | |
| 956 | ||
| 957 | /** | |
| 958 | * Used for debugging. | |
| 959 | */ | |
| 960 | @Override | |
| 961 | public String toString() { | |
| 962 |
1
1. toString : mutated return of Object value for org/apache/commons/collections4/list/TreeList$AVLNode::toString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new StringBuilder() |
| 963 | .append("AVLNode(") | |
| 964 | .append(relativePosition) | |
| 965 |
1
1. toString : negated conditional → NO_COVERAGE |
.append(',') |
| 966 | .append(left != null) | |
| 967 | .append(',') | |
| 968 | .append(value) | |
| 969 | .append(',') | |
| 970 |
1
1. toString : negated conditional → NO_COVERAGE |
.append(getRightSubTree() != null) |
| 971 | .append(", faedelung ") | |
| 972 | .append(rightIsNext) | |
| 973 | .append(" )") | |
| 974 | .toString(); | |
| 975 | } | |
| 976 | } | |
| 977 | ||
| 978 | /** | |
| 979 | * A list iterator over the linked list. | |
| 980 | */ | |
| 981 | static class TreeListIterator<E> implements ListIterator<E>, OrderedIterator<E> { | |
| 982 | /** The parent list */ | |
| 983 | private final TreeList<E> parent; | |
| 984 | /** | |
| 985 | * Cache of the next node that will be returned by {@link #next()}. | |
| 986 | */ | |
| 987 | private AVLNode<E> next; | |
| 988 | /** | |
| 989 | * The index of the next node to be returned. | |
| 990 | */ | |
| 991 | private int nextIndex; | |
| 992 | /** | |
| 993 | * Cache of the last node that was returned by {@link #next()} | |
| 994 | * or {@link #previous()}. | |
| 995 | */ | |
| 996 | private AVLNode<E> current; | |
| 997 | /** | |
| 998 | * The index of the last node that was returned. | |
| 999 | */ | |
| 1000 | private int currentIndex; | |
| 1001 | /** | |
| 1002 | * The modification count that the list is expected to have. If the list | |
| 1003 | * doesn't have this count, then a | |
| 1004 | * {@link java.util.ConcurrentModificationException} may be thrown by | |
| 1005 | * the operations. | |
| 1006 | */ | |
| 1007 | private int expectedModCount; | |
| 1008 | ||
| 1009 | /** | |
| 1010 | * Create a ListIterator for a list. | |
| 1011 | * | |
| 1012 | * @param parent the parent list | |
| 1013 | * @param fromIndex the index to start at | |
| 1014 | */ | |
| 1015 | protected TreeListIterator(final TreeList<E> parent, final int fromIndex) throws IndexOutOfBoundsException { | |
| 1016 | super(); | |
| 1017 | this.parent = parent; | |
| 1018 | this.expectedModCount = parent.modCount; | |
| 1019 |
1
1. |
this.next = parent.root == null ? null : parent.root.get(fromIndex); |
| 1020 | this.nextIndex = fromIndex; | |
| 1021 | this.currentIndex = -1; | |
| 1022 | } | |
| 1023 | ||
| 1024 | /** | |
| 1025 | * Checks the modification count of the list is the value that this | |
| 1026 | * object expects. | |
| 1027 | * | |
| 1028 | * @throws ConcurrentModificationException If the list's modification | |
| 1029 | * count isn't the value that was expected. | |
| 1030 | */ | |
| 1031 | protected void checkModCount() { | |
| 1032 |
1
1. checkModCount : negated conditional → NO_COVERAGE |
if (parent.modCount != expectedModCount) { |
| 1033 | throw new ConcurrentModificationException(); | |
| 1034 | } | |
| 1035 | } | |
| 1036 | ||
| 1037 | public boolean hasNext() { | |
| 1038 |
3
1. hasNext : changed conditional boundary → NO_COVERAGE 2. hasNext : negated conditional → NO_COVERAGE 3. hasNext : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return nextIndex < parent.size(); |
| 1039 | } | |
| 1040 | ||
| 1041 | public E next() { | |
| 1042 |
1
1. next : removed call to org/apache/commons/collections4/list/TreeList$TreeListIterator::checkModCount → NO_COVERAGE |
checkModCount(); |
| 1043 |
1
1. next : negated conditional → NO_COVERAGE |
if (!hasNext()) { |
| 1044 | throw new NoSuchElementException("No element at index " + nextIndex + "."); | |
| 1045 | } | |
| 1046 |
1
1. next : negated conditional → NO_COVERAGE |
if (next == null) { |
| 1047 | next = parent.root.get(nextIndex); | |
| 1048 | } | |
| 1049 | final E value = next.getValue(); | |
| 1050 | current = next; | |
| 1051 |
1
1. next : Replaced integer addition with subtraction → NO_COVERAGE |
currentIndex = nextIndex++; |
| 1052 | next = next.next(); | |
| 1053 |
1
1. next : mutated return of Object value for org/apache/commons/collections4/list/TreeList$TreeListIterator::next to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return value; |
| 1054 | } | |
| 1055 | ||
| 1056 | public boolean hasPrevious() { | |
| 1057 |
3
1. hasPrevious : changed conditional boundary → NO_COVERAGE 2. hasPrevious : negated conditional → NO_COVERAGE 3. hasPrevious : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return nextIndex > 0; |
| 1058 | } | |
| 1059 | ||
| 1060 | public E previous() { | |
| 1061 |
1
1. previous : removed call to org/apache/commons/collections4/list/TreeList$TreeListIterator::checkModCount → NO_COVERAGE |
checkModCount(); |
| 1062 |
1
1. previous : negated conditional → NO_COVERAGE |
if (!hasPrevious()) { |
| 1063 | throw new NoSuchElementException("Already at start of list."); | |
| 1064 | } | |
| 1065 |
1
1. previous : negated conditional → NO_COVERAGE |
if (next == null) { |
| 1066 |
1
1. previous : Replaced integer subtraction with addition → NO_COVERAGE |
next = parent.root.get(nextIndex - 1); |
| 1067 | } else { | |
| 1068 | next = next.previous(); | |
| 1069 | } | |
| 1070 | final E value = next.getValue(); | |
| 1071 | current = next; | |
| 1072 |
1
1. previous : Replaced integer subtraction with addition → NO_COVERAGE |
currentIndex = --nextIndex; |
| 1073 |
1
1. previous : mutated return of Object value for org/apache/commons/collections4/list/TreeList$TreeListIterator::previous to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return value; |
| 1074 | } | |
| 1075 | ||
| 1076 | public int nextIndex() { | |
| 1077 |
1
1. nextIndex : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return nextIndex; |
| 1078 | } | |
| 1079 | ||
| 1080 | public int previousIndex() { | |
| 1081 |
2
1. previousIndex : Replaced integer subtraction with addition → NO_COVERAGE 2. previousIndex : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return nextIndex() - 1; |
| 1082 | } | |
| 1083 | ||
| 1084 | public void remove() { | |
| 1085 |
1
1. remove : removed call to org/apache/commons/collections4/list/TreeList$TreeListIterator::checkModCount → NO_COVERAGE |
checkModCount(); |
| 1086 |
1
1. remove : negated conditional → NO_COVERAGE |
if (currentIndex == -1) { |
| 1087 | throw new IllegalStateException(); | |
| 1088 | } | |
| 1089 | parent.remove(currentIndex); | |
| 1090 |
1
1. remove : negated conditional → NO_COVERAGE |
if (nextIndex != currentIndex) { |
| 1091 | // remove() following next() | |
| 1092 |
1
1. remove : Replaced integer subtraction with addition → NO_COVERAGE |
nextIndex--; |
| 1093 | } | |
| 1094 | // the AVL node referenced by next may have become stale after a remove | |
| 1095 | // reset it now: will be retrieved by next call to next()/previous() via nextIndex | |
| 1096 | next = null; | |
| 1097 | current = null; | |
| 1098 | currentIndex = -1; | |
| 1099 |
1
1. remove : Replaced integer addition with subtraction → NO_COVERAGE |
expectedModCount++; |
| 1100 | } | |
| 1101 | ||
| 1102 | public void set(final E obj) { | |
| 1103 |
1
1. set : removed call to org/apache/commons/collections4/list/TreeList$TreeListIterator::checkModCount → NO_COVERAGE |
checkModCount(); |
| 1104 |
1
1. set : negated conditional → NO_COVERAGE |
if (current == null) { |
| 1105 | throw new IllegalStateException(); | |
| 1106 | } | |
| 1107 |
1
1. set : removed call to org/apache/commons/collections4/list/TreeList$AVLNode::setValue → NO_COVERAGE |
current.setValue(obj); |
| 1108 | } | |
| 1109 | ||
| 1110 | public void add(final E obj) { | |
| 1111 |
1
1. add : removed call to org/apache/commons/collections4/list/TreeList$TreeListIterator::checkModCount → NO_COVERAGE |
checkModCount(); |
| 1112 |
1
1. add : removed call to org/apache/commons/collections4/list/TreeList::add → NO_COVERAGE |
parent.add(nextIndex, obj); |
| 1113 | current = null; | |
| 1114 | currentIndex = -1; | |
| 1115 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
nextIndex++; |
| 1116 |
1
1. add : Replaced integer addition with subtraction → NO_COVERAGE |
expectedModCount++; |
| 1117 | } | |
| 1118 | } | |
| 1119 | ||
| 1120 | } | |
Mutations | ||
| 86 |
1.1 |
|
| 101 |
1.1 2.2 |
|
| 102 |
1.1 |
|
| 112 |
1.1 |
|
| 123 |
1.1 |
|
| 134 |
1.1 |
|
| 147 |
1.1 |
|
| 148 |
1.1 |
|
| 160 |
1.1 |
|
| 161 |
1.1 |
|
| 163 |
1.1 |
|
| 174 |
1.1 2.2 3.3 |
|
| 186 |
1.1 |
|
| 187 |
1.1 |
|
| 189 |
1.1 |
|
| 201 |
1.1 |
|
| 202 |
1.1 |
|
| 203 |
1.1 |
|
| 208 |
1.1 |
|
| 224 |
1.1 |
|
| 225 |
1.1 |
|
| 227 |
1.1 |
|
| 229 |
1.1 |
|
| 230 |
1.1 |
|
| 231 |
1.1 |
|
| 244 |
1.1 2.2 |
|
| 247 |
1.1 |
|
| 248 |
1.1 |
|
| 259 |
1.1 |
|
| 260 |
1.1 2.2 |
|
| 263 |
1.1 |
|
| 264 |
1.1 |
|
| 272 |
1.1 |
|
| 287 |
1.1 2.2 3.3 4.4 |
|
| 347 |
1.1 |
|
| 373 |
1.1 2.2 3.3 |
|
| 374 |
1.1 2.2 |
|
| 375 |
1.1 |
|
| 381 |
1.1 |
|
| 382 |
1.1 2.2 |
|
| 383 |
1.1 |
|
| 388 |
1.1 |
|
| 397 |
1.1 |
|
| 414 |
1.1 |
|
| 416 |
1.1 |
|
| 417 |
1.1 |
|
| 420 |
1.1 2.2 |
|
| 421 |
1.1 |
|
| 422 |
1.1 |
|
| 424 |
1.1 |
|
| 431 |
1.1 |
|
| 432 |
1.1 |
|
| 433 |
1.1 |
|
| 434 |
1.1 |
|
| 437 |
1.1 2.2 3.3 |
|
| 438 |
1.1 |
|
| 440 |
1.1 |
|
| 441 |
1.1 2.2 |
|
| 443 |
1.1 |
|
| 454 |
1.1 |
|
| 455 |
1.1 2.2 |
|
| 457 |
1.1 |
|
| 458 |
1.1 2.2 |
|
| 468 |
1.1 2.2 |
|
| 469 |
1.1 |
|
| 471 |
1.1 |
|
| 480 |
1.1 2.2 |
|
| 481 |
1.1 |
|
| 483 |
1.1 |
|
| 494 |
1.1 |
|
| 496 |
1.1 2.2 |
|
| 497 |
1.1 |
|
| 499 |
1.1 |
|
| 503 |
1.1 |
|
| 504 |
1.1 |
|
| 506 |
1.1 |
|
| 509 |
1.1 2.2 |
|
| 510 |
1.1 |
|
| 513 |
1.1 |
|
| 514 |
1.1 |
|
| 518 |
1.1 |
|
| 519 |
1.1 |
|
| 521 |
1.1 |
|
| 523 |
1.1 2.2 |
|
| 524 |
1.1 |
|
| 527 |
1.1 |
|
| 528 |
1.1 |
|
| 536 |
1.1 2.2 |
|
| 543 |
1.1 2.2 |
|
| 552 |
1.1 2.2 |
|
| 561 |
1.1 2.2 |
|
| 571 |
1.1 |
|
| 573 |
1.1 |
|
| 574 |
1.1 |
|
| 576 |
1.1 2.2 |
|
| 577 |
1.1 |
|
| 578 |
1.1 2.2 |
|
| 579 |
1.1 |
|
| 582 |
1.1 |
|
| 583 |
1.1 2.2 |
|
| 584 |
1.1 |
|
| 587 |
1.1 |
|
| 588 |
1.1 |
|
| 592 |
1.1 |
|
| 593 |
1.1 |
|
| 595 |
1.1 |
|
| 596 |
1.1 2.2 |
|
| 597 |
1.1 |
|
| 599 |
1.1 |
|
| 600 |
1.1 |
|
| 604 |
1.1 |
|
| 605 |
1.1 |
|
| 607 |
1.1 |
|
| 608 |
1.1 2.2 |
|
| 609 |
1.1 |
|
| 611 |
1.1 |
|
| 612 |
1.1 |
|
| 621 |
1.1 2.2 |
|
| 622 |
1.1 |
|
| 624 |
1.1 |
|
| 625 |
1.1 2.2 |
|
| 626 |
1.1 2.2 3.3 4.4 |
|
| 628 |
1.1 |
|
| 629 |
1.1 |
|
| 631 |
1.1 |
|
| 632 |
1.1 2.2 3.3 4.4 |
|
| 633 |
1.1 |
|
| 634 |
1.1 |
|
| 637 |
1.1 2.2 |
|
| 641 |
1.1 |
|
| 645 |
1.1 2.2 |
|
| 646 |
1.1 |
|
| 652 |
1.1 |
|
| 657 |
1.1 |
|
| 663 |
1.1 2.2 |
|
| 664 |
1.1 |
|
| 667 |
1.1 |
|
| 668 |
1.1 |
|
| 680 |
1.1 |
|
| 682 |
1.1 2.2 |
|
| 683 |
1.1 |
|
| 685 |
1.1 |
|
| 687 |
1.1 2.2 |
|
| 688 |
1.1 |
|
| 690 |
1.1 |
|
| 700 |
1.1 |
|
| 701 |
1.1 |
|
| 703 |
1.1 |
|
| 710 |
1.1 |
|
| 711 |
1.1 |
|
| 715 |
1.1 |
|
| 722 |
1.1 |
|
| 723 |
1.1 |
|
| 724 |
1.1 |
|
| 731 |
1.1 2.2 |
|
| 738 |
1.1 2.2 |
|
| 745 |
1.1 |
|
| 746 |
1.1 |
|
| 747 |
1.1 |
|
| 749 |
1.1 |
|
| 750 |
1.1 |
|
| 755 |
1.1 |
|
| 762 |
1.1 |
|
| 763 |
1.1 |
|
| 764 |
1.1 |
|
| 766 |
1.1 |
|
| 767 |
1.1 |
|
| 772 |
1.1 |
|
| 782 |
1.1 |
|
| 783 |
1.1 |
|
| 784 |
1.1 |
|
| 794 |
1.1 |
|
| 795 |
1.1 |
|
| 796 |
1.1 |
|
| 820 |
1.1 2.2 |
|
| 833 |
1.1 |
|
| 835 |
1.1 2.2 3.3 |
|
| 837 |
1.1 |
|
| 839 |
1.1 |
|
| 840 |
1.1 |
|
| 847 |
1.1 |
|
| 848 |
1.1 |
|
| 849 |
1.1 |
|
| 850 |
1.1 |
|
| 851 |
1.1 2.2 |
|
| 853 |
1.1 |
|
| 854 |
1.1 |
|
| 855 |
1.1 2.2 |
|
| 857 |
1.1 2.2 |
|
| 858 |
1.1 |
|
| 862 |
1.1 |
|
| 864 |
1.1 |
|
| 867 |
1.1 |
|
| 875 |
1.1 2.2 3.3 |
|
| 877 |
1.1 |
|
| 879 |
1.1 |
|
| 880 |
1.1 |
|
| 884 |
1.1 |
|
| 885 |
1.1 |
|
| 886 |
1.1 |
|
| 887 |
1.1 |
|
| 888 |
1.1 |
|
| 890 |
1.1 |
|
| 891 |
1.1 |
|
| 892 |
1.1 |
|
| 894 |
1.1 |
|
| 897 |
1.1 |
|
| 899 |
1.1 |
|
| 902 |
1.1 |
|
| 962 |
1.1 |
|
| 965 |
1.1 |
|
| 970 |
1.1 |
|
| 1019 |
1.1 |
|
| 1032 |
1.1 |
|
| 1038 |
1.1 2.2 3.3 |
|
| 1042 |
1.1 |
|
| 1043 |
1.1 |
|
| 1046 |
1.1 |
|
| 1051 |
1.1 |
|
| 1053 |
1.1 |
|
| 1057 |
1.1 2.2 3.3 |
|
| 1061 |
1.1 |
|
| 1062 |
1.1 |
|
| 1065 |
1.1 |
|
| 1066 |
1.1 |
|
| 1072 |
1.1 |
|
| 1073 |
1.1 |
|
| 1077 |
1.1 |
|
| 1081 |
1.1 2.2 |
|
| 1085 |
1.1 |
|
| 1086 |
1.1 |
|
| 1090 |
1.1 |
|
| 1092 |
1.1 |
|
| 1099 |
1.1 |
|
| 1103 |
1.1 |
|
| 1104 |
1.1 |
|
| 1107 |
1.1 |
|
| 1111 |
1.1 |
|
| 1112 |
1.1 |
|
| 1115 |
1.1 |
|
| 1116 |
1.1 |


The Progressive's Guide to Saving Democracy
Tips for Activists
- Set doable goals. For instance, aim to volunteer one day a month or to recruit one friend to volunteer with you. Once you achieve that goal, set a stretch goal, such as volunteering an extra day that month or enlisting more friends to get involved.
- Find an accountability buddy. Volunteering with friends is fun, especially helpful when trying times get you down. You can help keep each other motivated and remind each other of your commitment to enacting positive change.
- Pace yourself. It's easy to get super enthusiastic such that you expend a lot of energy at the outset, overcommitting to the point of burnout. It's OK to take a break. Prioritize self-care, whatever that looks like for you.
- Be resilient in the face of failure. Try not to take setbacks personally. Enacting change is a process. Inevitably you will take steps back but you will continue to forge forward.
- Celebrate your victories however insignificant they may seem in the grand scheme. Manage your expectations. Working within entrenched systems is difficult yet important. The mere act of doing something is worth celebrating. Reward yourself accordingly.
- Don't waste your time arguing with people on social media. Unless you really care about them. Even then, realize you might not get through to them. Project compassion. Spread facts.


Wool-meeting
She left me breathless in the morning
when I woke up
all -but only with a touch of her lips
- to find, it has been alone the feeling of a dream
What cannot be left up to be imagined?
For how -she alters me and predicates the night and darkness
The chemical that clouds my thoughts,
She, -the rain that predicates the clouds
She is the rain, my lover
splash colors
vibrate music
-radiate intensity so physically reactive
trusting not the world
starving and cold
-trampled and cut by ridiculous notions
So be it that I worry not
the beauty of my love is so
-en-grained
never understanding explanation
something larger did dispose
that which causes to believe
how a touch of love does feel-
we will send philosophy to ashes-
So that love may brush our lips


Before Change
def test_keypoints_dont_change(self):
// keypoints shouldnt be changed
keypoints = [ia.KeypointsOnImage([ia.Keypoint(x=0, y=0), ia.Keypoint(x=1, y=1),
ia.Keypoint(x=2, y=2)], shape=(11, 11, 1))]
aug = iaa.AverageBlur(k=3)
aug_det = aug.to_deterministic()
observed = aug.augment_keypoints(keypoints)
After Change
assert np.all([v > 0 for v in nb_seen.values()])
def test_keypoints_dont_change(self):
kps = [ia.Keypoint(x=0, y=0), ia.Keypoint(x=1, y=1),
ia.Keypoint(x=2, y=2)]
kpsoi = [ia.KeypointsOnImage(kps, shape=(11, 11, 1))]
aug = iaa.AverageBlur(k=3)
aug_det = aug.to_deterministic()
observed = aug.augment_keypoints(kpsoi)


The tool assists the user in assessing the proximity and impact of external risks to complex digital objects. Currently
A complex digital object is made up of interdependent simple digital objects or components (e.g. files, software applications, hardware specifications).
Currently the tool supports digital video artworks (DVAs) and space science experiments.
A DVA comprises a digital video and its playback environment. More precisely, this comprises a video file (compressed with a video codec and stored in a container or wrapper), a media player, an operating system and a computer.
A science experiment comprises a database for raw data, a script written in a specific scripting language, images and documents in specific formats together with associated viewers.
A visual representation of the object structures can be viewed by clicking on any object from the Collection View.
The main risk that occurs is availability of the components of the complex digital object. This can be caused through obsolescence of the components or failure of the associated hardware (e.g. computers).
Besides the type of the risk, the tool provides
The tool has separate areas form media and science. This can be selected on the landing page or from Start on the top menu bar.The UI is divided into three main parts.
The technical appraisal tool stores representations of the objects in a triple store (either the PERICLES Entity Registry Model Repository) or Fuseki. The objects themselves need to be stored in an external system, which could be an archive or repository.
The tool harvests and analyses data automatically from search engines, software repositories and Wikipedia.
The tool uses inbuilt digital ecosystem models for the media and science domains. These determine the component technologies used in the objects, the compatibility between those components and the transformation costs for replacing components. The models can be edited using the separate PERICLES-IBuilder application, but not currently through the technical appraisal tool UI.
A recovery option is a replacement of one or more components in an artwork. The objective of a recovery option is to move forward the date for action by replacing components at risk of obsolescence or failure, and thus extend the potential lifetime of the object. There are often multiple options depending on how far the date for action is moved forward. The intended retention period of the object will be a factor in selecting an appropriate recovery option. Also, the more changes that are made to the object, the more work that is required and hence the cost will be higher. The tool selects the optimal recovery options for a given object. Recovery options may involve transcoding video or image files, rewriting scripts or replacing hardware. If no recovery options are provided, then no actions are currently recommended.


Default behavior from tab has variable tab width.
Basic tab with Tab 5 active
property to true and
Tab 6 disabled
property to true.
Tab with fixedTabWidth
property to true.
Tab become scrollable when there a lot of tab item.
Swipeable tabs which can be used on touch enabled devices.
Tab can be customized using the following properties on the mz-tab
element.
mz-tab-item
will transclude any contents.


Recipe: Irish Soda Bread with Stout Butter
by CBS News"Sunday Morning" presents recipes from the kitchens of Tupperware.
"Bread and butter? Not quite. We're all Irish on St. Patrick's Day – be sure your table staple is, too!" [The instructions recommend a TupperWave Stack Cooker and Thatsa Bowl.]
Irish Soda Bread with Stout Butter
Makes 10 servings
Ingredients:
3 3/4 cups all-purpose flour
1 1/2 tsp. baking powder
1 1/2 tsp. cream of tartar
1 1/2 tsp. coarse kosher salt
4 tbsp. salted butter, room temperature
1 1/2 cups buttermilk
2 tbsp. dark molasses
2 tsp. toasted caraway seeds
2 tbsp. salted butter, melted (optional)
8 tbsp. unsalted butter (1 stick)
1 1/2 tbsp. Irish stout
2 tbsp. brown sugar
Preparation:
Prep the dough - Grease and flour 3-Qt. Casserole base and cone of the Tupperwave Stack Cooker. Place cone in center of Stack Cooker and set aside. In a Thatsa Large Bowl, whisk together flour, baking powder, cream of tartar and salt. Rub butter into flour mixture until coarse crumbs form. Create a well in the center of the flour. In a Thatsa Mini Bowl, whisk together buttermilk and molasses. Pour buttermilk mixture into the well. Using a spatula or fork, pull flour into the buttermilk until a crumbly dough forms. Knead dough briefly until dry pieces just come together; do not overmix. Dough will look scrappy and uneven.
Cook the dough - Drop 3" pieces of dough into the buttered Stack Cooker, forming a loose ring of dough around the cone. If desired, pour 2 tbsp. of melted butter over the top of the dough. Microwave on high power, uncovered, 8 minutes. Remove from microwave. Let stand 10 minutes before removing from Stack Cooker.
Make the glaze, store or serve - Meanwhile, make the butter. In a Thatsa Medium Bowl, stir together butter, stout and sugar until well combined. Refrigerate, covered, until ready to serve. Serve with sliced Irish Soda Bread.
For more info:


Just because you don't know a technology, doesn't mean you won't be called upon to work with it. --Mike Bongiovanni [ source]


Decomposition is the process of breaking down a problem into smaller more manageable parts that are easier to understand. The advantage of decomposition is that it allows for closer examination of each smaller problem
Object Oriented Programming is a language model organised around objects rather than actions. OOP is another form of decomposition as objects are broken down into fields, much like a table in a database. OOP, computer programs are designed by making them out of objects that interact with one another.
Abstractions are important as they allow us to create a general idea of what a problem is and how to solve it. The process instructs us to remove all specific detail, and any patterns that will not help us solve our problem. This helps us form our idea of the problem. It is important to use abstracrtion in order to be able solve a problem as otherwise there would be too much information.
The diffrence between an abstraction and reality is
Backtracking can be used if something is lost and you can think back to the last time you saw that thing.
Data Mining is used to search through different sets of data which wouldn’t normally be put in the same database so the computer must search in different sources. This could be checking what the weather was like compared to how many people went shopping on a certain day
Performance Monitoring is where different situations are simulated. This is good as it means different approaches can be tested without any real risk. This might be used by testing how the weight distribution in a building might affect the structure and this would be done in 3D modelling software.
Pipelining is where one core sends data to another one to form a production line.
To think abstractly means to filter out all unneeded information and pick out the required information. This may mean simplifying certain things that aren't required. Such as in designing a map, every single plant and person isn’t needed and would actually overcrowd the map and make it difficult to read, therefore they are not included.
Thinking procedurally means breaking tasks down and doing one after another. A system that has to do this is an online ordering system has many parts to it such as customer records, order processing and invoice production. To create a single program that could do all of these would be highly unlikely to succeed so multiple programs are used for each of the smaller tasks.
This means doing multiple things at a time which is what multiple cores are used for.
Heuristics means sacrificing complete accuracy for speed. Heuristics are sometimes used when getting an exact answer isn't possible.


First name First name is required
Last name Last name is required
E-mail E-mail address name is required Please enter valid e-mail address in format e.g. "user@xyz.com"


Welcome to my Apache server. This server acts as a reverse proxy for my API Hub.
© 2019 Hans de Rooij
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Type that offers methods for managing authentication and users of the Firebase. More...
| Import Statement: | import Firebase 1.0 |
FirebaseAuth provides methods for authenticating on the Firebase and also managing the accounts such as changing password or email, sending password reset requests and updating profile data. Authentication is necessary if the rules on the Firebase project are set in such a way that authentication is required for writing to the database. After logging in, the property currentUser holds a reference to the authenticated user of type FirebaseUser.
This property holds the API Key of the Firebase project, passed from FirebaseApp.
currentUser : FirebaseUser |
Holds a reference to the user that is currently logged in. Typically used to access the idToken of the user for actions that require authentication, for example:
FirebaseApp { id: fbApp } FirebaseAuth { id: fbAuth apiKey: fbApp.apiKey onSignedIn: { fbAuth.getUserData(currentUser.idToken) // Fetches audio data from database fbDb.getValue("/Audio/.json", fbAuth.currentUser.idToken, codes.audioDataCode) // Adds the listeners to these locations of the database fbDb.listenEvents("/Audio/.json", fbAuth.currentUser.idToken, codes.audioDataCode) fbDb.listenEvents("/Users/.json", fbAuth.currentUser.idToken, codes.userDataCode) } } FirebaseDatabase { id: fbDb ... }
See also FirebaseUser.
Emitted when an error ocurred with the corresponding error in human readable format.
Note: The corresponding handler is onErrorOcurred
.
Emitted when a user successfully authenticates.
Note: The corresponding handler is onSignedIn
.
See also currentUser.
Changes the email of the user with idToken to the new email newEmail.
See also changePassword().
Changes the password of the user with idToken to the new password newPassword.
See also changeEmail().
Exchanges a refreshToken for an ID token. When the user authenticates, both of these tokens are received. The ID token is necessary for all requests to the Firebase but has a short lifetime of 1 hour and needs to be refreshed with the refresh token by calling this method. When the response is received, the ID token is automatically updated on the currentUser.
Retrieves information about the user with idToken, tipically the currentUser and automatically updates its properties.
Updates the fields name and photoUrl of the user with idToken.
Sends verification email to the user with idToken.
See also sendPasswordResetEmail().
Calls a login request with email and password. If successful emits signals signedIn() and updates currentUser to the user, otherwise if an error occurs (e.g incorrect email/password, no network access) the signal errorOcurred is emited with the error string.
Authenticates user with Google's authToken and providerId.
Registers a new account in the Firebase of user with name, email and password. If successful emits signals signedIn() otherwise if an error occurs (e.g invalid email/password, no network access) then the signal errorOcurred() is emited with the error string.
Note: password must be a minimum of 6 characters.


Neil Lennon challenges Celtic to win Europa League group
Neil Lennon insists Celtic will be going all out to finish top of their Europa League section despite having already qualified for the last 32 ahead of the visit of Rennes on Thursday.
The Hoops' 2-1 win over Lazio in Rome on November 7 kept the Scottish champions top of Group E with 10 points from four matches and guaranteed them European football after Christmas.
The Parkhead side have two group games left, at home to the French side and away at Cluj and they are one point ahead of the Romanian outfit.
Amidst a busy fixture period where his side are fighting a tense Ladbrokes Premiership title battle with Rangers, with an OId Firm Betfred Cup final coming up, Lennon is adamant that their favourable European position will not affect his thinking when it comes to team selection.
The Hoops boss told Celtic's YouTube channel: "No, we want to win it.
"We want to win the group and try to get maximum points from the home games in Europe.
"The fans crave that, they deserve that and that's what we will be setting out the team to do.
"If we can finish top of the table before Christmas it will be really advantageous for us going into the second half of the season."
Lennon praised Celtic's hunger for goals following the 4-0 win over Livingston at Parkhead on Saturday.
The Hoops were cruising to victory after goals from French striker Odsonne Edouard, a deflected strike by skipper Scott Brown and a volley from winger James Forrest but refused to be content.
Forrest grabbed himself a second in the four added minutes as Celtic racked up their eighth successive win in all competitions since losing to Livi in West Lothian last month.
The former Celtic midfielder said: "To score in the 93rd minute pleases me as well because we keep going and are hungry for goals.
"At the minute, we are in a very good place.
"I was more than happy with that. It was just an outstanding performance from start to finish.
"We could have been a few up at half-time, we were playing so well with great control of the game and great energy.
"Livingston are a tough team to beat.
"We scored a great first goal and I talked to them at half-time and said, 'can you go out and pour it on in the second half?' and we did that.
"An all-round great performance."
body check tags ::


🤖 My Engineered Solution¶
- First and foremost, it should be open sourced on GitHub.
- <https://github.com/infamousjoeg/aws-ec2-cloudflare-lambda>
- Language should be [Python](https://www.python.org/). _(My most comfortable language currently.)_
- Any custom functions should be put in a [Python module package](https://docs.python.org/2/tutorial/modules.html) format
for easy distribution later.
- The AWS Lambda function's [execution
role](https://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambda-intro-execution-role) should have the following permissions:
- [CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)
- [SNS](https://aws.amazon.com/sns/) (_Publish_)
- EC2 (_EC2ReadOnlyAccess_ IAM Role)
- The _Instance State_ change should be a [CloudWatch Event
trigger](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/Create-CloudWatch-Events-Rule.html) in the function.
- The function should be universally adoptable. It should make the following variables available to the Python script as
Environment Variables:
- EC2_INSTANCE_NAME
- CLOUDFLARE_EMAIL
- CLOUDFLARE_API_KEY
- CLOUDFLARE_A_NAME
- CLOUDFLARE_DNS_ID
- CLOUDFLARE_ZONE_ID
- The function should use the [AWS SDK](https://aws.amazon.com/sdk-for-python/) to describe the EC2 instance provided and
retrieve the public IPv4 address assigned.
- The function should use [Cloudflare's RESTful API](https://api.cloudflare.com/) to update the specified A record in the
DNS & Zone given using the E-Mail and API Key provided for authentication to do so. Updating it to the previously retrieved public IPv4 address.


Looks like this
you know, for reference
Your mileage may vary
<style>
tag on top of the page. Boom! One request to render, no cache WTFs. And GZIP loved it.typeof window !== 'undefined'
Single-page applications give you tons of performance but you pay a high toll
componentWillUnmount
and friends allows third parties to mess with the DOM in a pretty sane way
var once = require('once')
var promisescript = require('promisescript')
module.exports.googleCustomSearch = once(() =>
new Promise((resolve) => {
window.__gcse = { ... }
promisescript({...})
})
)
module.exports.omniture = once(() =>
promisescript(...).then(window.s_gi))
thirdParty().then(whatever)
if (/&TEST=1/.test(location.href)) {
window.loadThirdParties = Promise.all([
thirdParty1(),
thirdParty2(),
...
])
window.startApplication = startApplication
} else {
startApplication()
}
function startApplication() {
ReactDOM.render(...)
}
hopefullyNotNightwatchJs.runOnClient((done) => {
window.loadThirdParties().then(() => {
sinon.spy(window, 's_gi')
window.startApplication()
assert(window.s_gi.calledOnce)
assert(window.s_gi.calledWith({
/* the exact analytics data you expect */
}))
}).then(done, done)
})
Query all the things!
Here's a query that queries the things on the homepage, their titles, their children, and their children's titles.
{
# stuff to put on the home page
content(url: "/") {
title,
children {
title
children {
title
}
}
}
}
module.exports = new GraphQLSchema({
name: 'query',
fields: () => ({
content: {
type: ContentType,
args: { url: { type: GraphQLString } },
resolve: (self, { url }) => myGetters.getContentByURL(url)
}
})
})
var ContentType = new GraphQLObjectType({
name: 'Content',
fields: () => ({
id: { type: GraphQLInt },
title: { type: GraphQLString },
children: {
type: new GraphQLList(ContentType),
resolve: (self) => myGetters.getChildContentOf(self.id)
}
})
})
return someJSON
Disclaimer: we chose not to use this
{
postThatWorks: post(id: "12345") { ... }
postThatFails: post(id: "-1") { ... }
}
// the above query responds...
{
data: {
postThatWorks: { ... },
postThatFails: null
},
errors: [ { message: '404 message from your code' } ]
}
We didn't want partial responses so we had to read this errors
array and fail with an error code. hapi makes this easy with the onPreResponse hook.
It's awesome. Use it for debugging and query building
graphqlConfig = {
query: (request) => ({
schema: graphQLSchema,
rootValue: {
requestId: request.id,
log: (...args) => request.log(...args),
}
}),
route: // ...
if you're using it or plan to use it
/graphql/v2
later.wget
their demo page and serve it in development mode. It just works.Here's a reusable comment section component with a declaration of what data it needs
function CommentsList(props) {
var comments = props.contentItem.comments
.map((c, i) => (<CommentListItem comment={c} key={c.id} />))
return ({comments})
}
module.exports = Relay.createContainer(CommentsList, {
fragments: {
contentItem: () => Relay.QL`
fragment on Content {
id,
commentCount,
comments {
id,
${ CommentListItem.getFragment('comment') }
}
}
`
}
})
Here's a reusable comment item Relay container
function Comment(props) {
return (
<div className="comment__container">
<UserInfo user={props.comment.author} />
{props.comment.text}
</div>
)
}
module.exports = Relay.createContainer(CommentsList, {
fragments: {
comment: () => Relay.QL`
fragment on Comment {
id,
text,
author { ${ UserInfo.getFragment('user') } }
}
`
}
})
<script type="application/json">{Data to poison Relay's cache}</script>
const queyGraphQL = (ql) => new Promise((resolve, reject) => {
const querySet = {
query: Relay.createQuery(ql, variables),
};
Relay.Store.primeCache(querySet, ({ done, error }) => {
if (done) {
const response = Relay.Store.readQuery(querySet.query);
resolve(response[0]);
}
if (error) {
reject(error);
}
});
});
it('should provide us with beautiful, beautiful data', () => {
return queryGraphQL(Relay.QL`
query {
content (path: "/actual/url/in/website") {
fieldWhichShouldBeTrue,
${ LatestPrinted.getFragment('latestIssue') }
}
}
`).then((res) => {
fieldWhichShouldBeTrue.should.equal(true);
});
});
What have I learned?
Questions?


TFileBrowseEvent = procedure(Sender, Obj: TObject; var S: string) of Object;
The TMetaType type points to a method that might process the contents of a <META> HTML tag. Sender is the THtmlViewer which encounters the <META> tag. The other three parameters are the values of <META> tag attributes with the same name.
See also:


Permanently deletes the specified user from the portal. The user must be deleted already. If you issue a get-user
command and the IsDeleted
property isn't true
, then you will get an error when attempting this command. You must use the delete-user
command on the user first.
| Flag | Type | Required | Default | Description |
|---|---|---|---|---|
| --id | integer | Yes | The user's User ID. If the flag is not used, then the user's ID must be the first argument. |
Permanently delete's the user with a User ID of 345. If you issue the command: get-user 345
you will receive a 'user not found' message.
purge-user 345
This is the more explicit form of the above code.
purge-user --id 345


Modular Architectures in JS
JS (programming in general) has a fanaticism problem.
"When you have a hammer..."
Fanaticism prevents us from building the best software by artifically limiting our available solutions.
Need an example? Check Twitter. Any day. Really.
Modular Architecture
Stop only asking "How is [X] like [my favorite]."
Start asking "How will [X] make my code/process/life better?"
Be passionate, but not fanatic, about the tools you use.
Avoid common developer assumptions
I'm not saying don't use a framework, ever.
Consider the following:
- Is it bringing in functionality I don't need?
- Can I bring in outside code easily?
- What's the investment-to-reward ratio?
Proof of Concepts
Building a POC allows you to relatively quickly determine the cost-to-benefit ratio of a particular tool.
- Write more than 'Hello World'
- Consider the tasks you need the tool to accomplish
- Keep your team's eccentricities in mind / don't build in a vacuum.
This is usually where I'm barraged with arguments
Modular systems cause spaghetti code!
- Tying together all the modules becomes an unmantainable mess.
- My favorite framework solves this by including everything OR having a plugin system
separate module choices from your code
- Abstraction Layers
- Functional Mixins
- Architecture Assistance
Abstraction Layers
Abstraction layers mean you can swap out modules without editing every reference to that module
They also mean you can create a consistent style and language for your code
Example: Primus
Functional Mixins
Augment your code without creating a direct dependency
"Architecture Assistance"
Definition of 'Framework':
"the basic structure of something : a set of ideas or facts that provide support for something" - http://www.merriam-webster.com/
Good Examples:
What you get
- Swap out modules with minimal work
- Modify abstraction layer, run the tests on your code, done.
My Framework has everything my team needs.
- Why would I spend tons of time picking each and every module?
- Everything moves much quicker when I use a framework
- My team all speaks the same language this way
This is one argument where fanticism really shows.
I see it often, myself.
- All-in-one Frameworks tend to have a steep learning curve
- This can mean long ramp-ups to productivity
Don't hold your application hostage
- Pick the right tool for each task
- Don't settle for one huge library that does some things you need well at the expense of other tasks.
Third-Party module management is a nightmare.
We have the technology...
Package Management
(Client-side) Module Loading
(Also, ES6 is coming!)
Package management + module loading + CI
=
significant reduction in nightmares
To re-iterate
- Be passionate, not fanatic
- Be skeptical of large buy-in
- Pick the right tool for each task
- If you use a framework, be judicious
Why bother?
- Abstractions create a common language/way of doing things
- Everything you need, nothing you don't
- Self-contained modules === easier, less brittle testing.
Because developer hapiness is contagious
a brief word of thanks
Thanks for Listening!
Questions? Comments? Come find me!
@kassandra_perch
<EMAIL_ADDRESS>Engineering Evangelist, RetailMeNot