Takes an elements and a list and returns a new list with both.

@param head the first element
@param tail the rest of the elements
@return a list with all elements
963720
private List<String> joinList(final String head, final List<String> tail) {
        return new AbstractList<String>() {

            @Override
            public String get(int index) {
                if (index == 0) {
                    return head;
                } else {
                    return tail.get(index - 1);
                }
            }

            @Override
            public int size() {
                return tail.size()+1;
            }
        };
    }
1258951
public static <E> List<E> union(final List<? extends E> list1, final List<? extends E> list2) {
		final List<E> result = new ArrayList<E>(list1.size() + list2.size());
		result.addAll(list1);
		result.addAll(list2);
		return result;
	}
645505
def tail(self) -> 'List':
        """"""

        lambda_list = self._get_value()
        return List(lambda_list(lambda _, tail: tail))
146675
public static <T> T[] offerArray(T[] prepend, T[] tail) {
        if (prepend == null || prepend.length < 1) {
            return tail;
        } else if (tail == null || tail.length < 1) {
            return prepend;
        } else {
            T[] result = newArrayInstance(tail, prepend.length + tail.length);
            System.arraycopy(prepend, 0, result, 0, prepend.length);
            System.arraycopy(tail, 0, result, prepend.length, tail.length);
            return result;
        }
    }
1270846
public QueueElement removeTail() {

		if (head == null) {
			return null;
		}

		QueueElement result = tail;
		if (result.previous == null) {
			head = null;
			tail = null;
		} else {
			tail = result.previous;
			tail.next = null;
		}
		result.previous = null;
		result.next = null;
		result.queue = null;

		numElements--;
		return result;

	}
224677
public static <T> List<T> copy(final List<T> list) {
		if (list == null) {
			return null;
		}

		TypeEnum elementType = null;
		List<T> copy = new ArrayList<T>();
		for (T element : list) {
			T elementCopy = null;
			if (element != null) {
				if (elementType == null) {
					elementType = TypeEnum.dataTypeOf(element.getClass());
				}
				elementCopy = copy(element, elementType);
			}

			copy.add(elementCopy);
		}

		return copy;
	}
622685
public static <T> List<T> toList(Iterable<T> iterable) {
        List<T> list = null;

        if (iterable != null) {
            list = new ArrayList<>();
            for (T elem : iterable) {
                list.add(elem);
            }
        }

        return list;
    }
578716
public static <T> List<T> intersection(final List<? extends T> list1, final List<? extends T> list2) {
		List<? extends T> smaller = list1;
		List<? extends T> larger = list2;
		if (list1.size() > list2.size()) {
			smaller = list2;
			larger = list1;
		}

		// 克隆一个可修改的副本
		List<T> newSmaller = new ArrayList<T>(smaller);
		List<T> result = new ArrayList<T>(smaller.size());
		for (final T e : larger) {
			if (newSmaller.contains(e)) {
				result.add(e);
				newSmaller.remove(e);
			}
		}
		return result;
	}
554768
def edge_by_node(self, head, tail):
        
        for edge in self.out_edges(head):
            if self.tail(edge) == tail:
                return edge
        return None
715869
public function lranges($key, $head, $tail){
		return $this->driver->lrange($key, $head, $tail);
	}
192408
public static <T> List<T> createList(T... args) {
        ArrayList<T> newList = new ArrayList<T>();
        Collections.addAll(newList, args);
        return newList;
    }
215790
function(id, head, tail) {
        head = head || '';
        tail = tail || id;

        if (this.arch.hasNode(id)) return Q.resolve(id);
        if (head === id) return Q.reject(UTIL.format('Node "%s" not found', id));

        var parts = tail.split(PATH.dirSep),
            p = parts.shift();
        head = (head? [head, p] : [p]).join(PATH.dirSep);
        tail = parts.join(PATH.dirSep);

        var _this = this,
            magicHead = head + '*';
        if (!this.arch.hasNode(magicHead)) {
            return this.findNode(id, head, tail);
        }

        return this.process(magicHead).then(function() {
            return _this.findNode(id, head, tail);
        });
    }
1040379
protected <T extends BasicInclude> T aggregateList(final MessageDigest digest, final Deque<T> elements, 
	        final List<File> skinDirectories, final File outputRoot, final File alternateOutput, 
	        final String extension, final AggregatorCallback<T> callback) throws IOException {
	    
        if (null == elements || elements.size() == 0) {
            return null;
        }

		// reference to the head of the list
        final T headElement = elements.getFirst();
        if (elements.size() == 1 && this.resourcesDao.isAbsolute(headElement)) {
            return headElement;
        }
        
        final File tempFile = File.createTempFile("working.", extension);
        final File aggregateOutputFile;
        try {
            //Make sure we're working with a clean MessageDigest
            digest.reset();
            TrimmingWriter trimmingWriter = null;
            try {
                final BufferedOutputStream bufferedFileStream = new BufferedOutputStream(new FileOutputStream(tempFile));
                final MessageDigestOutputStream digestStream = new MessageDigestOutputStream(bufferedFileStream, digest);
                final OutputStreamWriter aggregateWriter = new OutputStreamWriter(digestStream, this.encoding);
                trimmingWriter = new TrimmingWriter(aggregateWriter);
                
                for (final T element: elements) {
                    final File resourceFile = this.findFile(skinDirectories, element.getValue());
                    
                    FileInputStream fis = null;
                    try {
                        fis = new FileInputStream(resourceFile);
                        final BOMInputStream bomIs = new BOMInputStream(new BufferedInputStream(fis));
                        if (bomIs.hasBOM()) {
                            logger.debug("Stripping UTF-8 BOM from: " + resourceFile);
                        }
                        final Reader resourceIn = new InputStreamReader(bomIs, this.encoding);
                        if (element.isCompressed()) {
                            IOUtils.copy(resourceIn, trimmingWriter);
                        }
                        else {
                            callback.compress(resourceIn, trimmingWriter);
                        }
                    }
                    catch (IOException e) {
                        throw new IOException("Failed to read '" + resourceFile + "' for skin: " + skinDirectories.get(0), e);
                    }
                    finally {
                        IOUtils.closeQuietly(fis);
                    }
                    trimmingWriter.write(SystemUtils.LINE_SEPARATOR);
                }
    		}
            finally {
                IOUtils.closeQuietly(trimmingWriter);
            }
            
            if (trimmingWriter.getCharCount() == 0) {
                return null;
            }
    
    		// temp file is created, get checksum
    		final String checksum = Base64.encodeBase64URLSafeString(digest.digest());
    		digest.reset();
    
    		// create a new file name
    		final String newFileName = checksum + extension;
    
    		// Build the new file name and path
    		if (alternateOutput == null) {
    		    final String elementRelativePath = FilenameUtils.getFullPath(headElement.getValue());
    	        final File directoryInOutputRoot = new File(outputRoot, elementRelativePath);
    	        // create the same directory structure in the output root
    	        directoryInOutputRoot.mkdirs();
    
    	        aggregateOutputFile = new File(directoryInOutputRoot, newFileName).getCanonicalFile();
    		}
    		else {
    		    aggregateOutputFile = new File(alternateOutput, newFileName).getCanonicalFile();
    		}
    		
    		//Move the aggregate file into the correct location
    		FileUtils.deleteQuietly(aggregateOutputFile);
            FileUtils.moveFile(tempFile, aggregateOutputFile);
        }
        finally {
            //Make sure the temp file gets deleted
            FileUtils.deleteQuietly(tempFile);
        }

		final String newResultValue = RelativePath.getRelativePath(outputRoot, aggregateOutputFile);
		
		this.logAggregation(elements, newResultValue);
		
		return callback.getAggregateElement(newResultValue, elements);
	}
371997
public static <T> T head(Iterable<T> iterable) {
		return IteratorExtensions.head(iterable.iterator());
	}
977615
@Nonnull
    public final ArrayList<A> toArrayList() {
        ArrayList<A> list = new ArrayList<>(this.length);
        ImmutableList<A> l = this;
        for (int i = 0; i < length; i++) {
            list.add(((NonEmptyImmutableList<A>) l).head);
            l = ((NonEmptyImmutableList<A>) l).tail;
        }
        return list;
    }
503173
public Header[] head(String endpoint, String params) throws IOException {
        return this.head(endpoint, params, "");
    }
899348
public void addToTail(QueueElement qe) {

		checkElementFree(qe);
		if (head == null) {
			head = qe;
			tail = qe;
			qe.queue = this;
		} else {
			qe.previous = tail;
			qe.next = null;
			tail.next = qe;
			tail = qe;
		}

		qe.queue = this;
		numElements++;

	}