查看了下linkedlist的源码,其remove(Object o)的源码如下: 

Java代码 
  1. public boolean remove(Object o) {  
  2.     if (o==null) {  
  3.         for (Entry e = header.next; e != header; e = e.next) {  
  4.             if (e.element==null) {  
  5.                 remove(e);  
  6.                 return true;  
  7.             }  
  8.         }  
  9.     } else {  
  10.         for (Entry e = header.next; e != header; e = e.next) {  
  11.             if (o.equals(e.element)) {  
  12.                 remove(e);  
  13.                 return true;  
  14.             }  
  15.         }  
  16.     }  
  17.     return false;  
  18. }  


在remove时,传入的o被作为一个值与各个entry进行比较,比较到合适的对象再去删除 
由于有个查找的过程,因此,其时间复杂度为O(n) + O(1) = O(n) 

 

readable angular tests

In this post, I'll provdes some tips to create readable angular test.### General Tips#### Use describe or nested describe to structure sp...… Continue reading

Exposing event stream from monolith

Published on September 18, 2017