如果before为true则把key移动到ref前面，否则把key移动到ref后面

@param list
@param key
@param ref
@param keyMapper
@param before
@return 被移动的元素移动后在列表中的位置，-1表示没有被移动
185062
public static <T, K> List<T> move(List<T> list, K key, K ref,
			Function<T, K> keyMapper, boolean before,
			Function<T, Integer> orderGet, OrderSetter<T> orderSet, int orderGap) {
		if (key == ref)
			return null;

		// { 找到要移动的项和参考项所在位置
		int keyidx = -1;
		int refidx = -1;
		int idx = 0;

		for (T t : list) {
			K id = keyMapper.apply(t);
			if (id.equals(key))
				keyidx = idx;
			if (id.equals(ref))
				refidx = idx;

			if (keyidx != -1 && refidx != -1)
				break;

			idx++;
		}

		if (keyidx == -1 || refidx == -1)
			return null;
		// }

		// { 拿走要移动的项
		T t = list.remove(keyidx);
		if (refidx >= keyidx)
			refidx--;

		if (!before)
			refidx++;
		// }

		// 放回要移动的项
		list.add(refidx, t);

		// { 设置排序位置
		ArrayList<T> moved = new ArrayList<T>();

		int startOrder = 0;
		if (refidx > 0)
			startOrder = orderGet.apply(list.get(refidx - 1));

		for (int i = refidx + 1; i < list.size(); i++) {
			int order = orderGet.apply(list.get(i));
			if (order - startOrder >= i - refidx + 1) {
				int gap = (order - startOrder) / (i - refidx + 1);
				for (int j = refidx; j < i; j++) {
					T move = list.get(j);

					orderSet.apply(move, startOrder + (j - refidx + 1) * gap);
					moved.add(move);
				}

				return moved;
			}
		}

		for (int i = refidx; i < list.size(); i++) {
			T move = list.get(i);

			orderSet.apply(move, startOrder + (i - refidx + 1) * orderGap);
			moved.add(move);
		}

		return moved;
		// }
	}
1279929
def tree_list(ref)
      if (sha = @access.ref_to_sha(ref))
        commit = @access.commit(sha)
        tree_map_for(sha).inject([]) do |list, entry|
          next list unless @page_class.valid_page_name?(entry.name)
          list << entry.page(self, commit)
        end
      else
        []
      end
    end
115058
public static <K, V> void putIntoListMap(K key, V value, Map<? super K, List<V>> map) {
		List<V> list = map.get(key);
		if (list == null) {
			list = Lists.newArrayListWithCapacity(2);
			map.put(key, list);
		}
		list.add(value);
	}
25377
public static <K, V, E extends Exception> boolean removeIf(final Map<K, V> map, final Try.Predicate<? super Map.Entry<K, V>, E> filter) throws E {
        List<K> keysToRemove = null;

        for (Map.Entry<K, V> entry : map.entrySet()) {
            if (filter.test(entry)) {
                if (keysToRemove == null) {
                    keysToRemove = new ArrayList<>(7);
                }

                keysToRemove.add(entry.getKey());
            }
        }

        if (N.notNullOrEmpty(keysToRemove)) {
            for (K key : keysToRemove) {
                map.remove(key);
            }

            return true;
        }

        return false;
    }
1116519
public List<V> removeAll(K key) {
		key = sanitizeKey(key);
		List<V> removed = map.remove(key);
		if (removed == null) {
			return Collections.emptyList();
		}

		List<V> unmodifiableCopy = Collections.unmodifiableList(new ArrayList<V>(removed));
		removed.clear();
		return unmodifiableCopy;
	}
508596
@Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        for (int i = 0; i < mWatchers.size(); i++) {
            int key = mWatchers.keyAt(i);
            if(mEnabledKeys.get(key)) {
                mWatchers.valueAt(i).beforeTextChanged(s, start, count, after);
            }
        }
    }
739355
private static void addRef(Map refs, String key, JSDynamic unres) {
    List thisKey = (List) refs.get(key);
    if (thisKey == null) {
      thisKey = new ArrayList();
      refs.put(key, thisKey);
    }
    thisKey.add(unres);
  }
853652
public static <T> T getLast(List<T> list)
    {
        if (list == null)
        {
            return null;
        }
        if (list instanceof RandomAccess)
        {
            return RandomAccessListIterate.getLast(list);
        }
        ListIterator<T> iterator = list.listIterator(list.size());
        if (iterator.hasPrevious())
        {
            return iterator.previous();
        }
        return null;
    }
725429
public boolean containsKey(Object key) {
        Entry tab[] = mTable;

        if (key != null) {
            int hash = key.hashCode();
            int index = (hash & 0x7FFFFFFF) % tab.length;
            for (Entry e = tab[index], prev = null; e != null; e = e.mNext) {
                if (e.getValue() == null) {
                    // Clean up after a cleared Reference.
                    mModCount++;
                    if (prev != null) {
                        prev.mNext = e.mNext;
                    }
                    else {
                        tab[index] = e.mNext;
                    }
                    mCount--;
                }
                else if (e.mHash == hash && key.equals(e.mKey)) {
                    return true;
                }
                else {
                    prev = e;
                }
            }
        }
        else {
            for (Entry e = tab[0], prev = null; e != null; e = e.mNext) {
                if (e.getValue() == null) {
                    // Clean up after a cleared Reference.
                    mModCount++;
                    if (prev != null) {
                        prev.mNext = e.mNext;
                    }
                    else {
                        tab[0] = e.mNext;
                    }
                    mCount--;
                }
                else if (e.mKey == null) {
                    return true;
                }
                else {
                    prev = e;
                }
            }
        }

        return false;
    }
622138
@Override
  public List<String> put(String key, List<String> value) {
    return getMap().put(key, value);
  }
878415
public void insertAfter(Token before, TokenList list ) {
        Token after = before.next;

        before.next = list.first;
        list.first.previous = before;
        if( after == null ) {
            last = list.last;
        } else {
            after.previous = list.last;
            list.last.next = after;
        }
        size += list.size;
    }
820650
function makeKeyIndexAndFree (list, key) {
  var keyIndex = {}
  var free = []
  for (var i = 0, len = list.length; i < len; i++) {
    var item = list[i]
    var itemKey = getItemKey(item, key)
    if (itemKey) {
      keyIndex[itemKey] = i
    } else {
      free.push(item)
    }
  }
  return {
    keyIndex: keyIndex,
    free: free
  }
}
469689
static final Map<String, Object> previousAndCurrentToDelta(List<Map<String, Object>> data) {
        if (data.size() == 2) {
            Map<String, Object> previous = data.get(0);
            Map<String, Object> current = data.get(1);
            return previousAndCurrentToDelta(previous, current);
        } else {
            throw new IllegalArgumentException("Must be list of 2 items");
        }

    }
857693
private void removeKey(Key k, List<Key>[] vector) {
    if (k == null) {
      throw new NullPointerException("Key can not be null");
    }
    if (vector == null) {
      throw new NullPointerException("ArrayList<Key>[] can not be null");
    }

    int[] h = hash.hash(k);
    hash.clear();

    for (int i = 0; i < nbHash; i++) {
      vector[h[i]].remove(k);
    }
  }
976690
public static boolean valueChanged(Map<String, String> before, Map<String, String> after) {
        if ((before == null && after == null) || after == null) {
            return false;
        }
        if (before == null) {
            if (after.isEmpty()) {
                return false;
            } else {
                return true;
            }
        } else {
            if (before.size() != after.size()) {
                return true;
            }
            for (Entry<String, String> entry : after.entrySet()) {
                String key =  entry.getKey();
                String afterValue = entry.getValue();
                if (!before.containsKey(key)) {
                    return true;
                }
                String beforeValue = before.get(key);
                if (valueChanged(beforeValue, afterValue)) {
                    return true;
                }
            }
        }
        return false;
    }
724345
public static <T, K> boolean moveUp(List<T> list, K key,
			Function<T, K> keyMapper, int n) {
		if (list == null)
			return false;
		ArrayList<T> newList = new ArrayList<T>();
		boolean changed = false;
		for (int i = 0; i < list.size(); i++) {
			T item = list.get(i);

			if (i > 0 && key.equals(keyMapper.apply(item))) {
				int posi = i - n;
				if (posi < 0)
					posi = 0;
				newList.add(posi, item);
				changed = true;
			} else
				newList.add(item);
		}

		if (changed) {
			list.clear();
			list.addAll(newList);
			return true;
		}
		return false;
	}
858820
public List getAll(Object key) {
        Object value = mMap.get(key);
        if (value instanceof List) {
            return ((List)value);
        }
        else {
            List list = new ArrayList();
            if (value != null || mMap.containsKey(key)) {
                list.add(value);
            }
            mMap.put(key, list);
            return list;
        }
    }