All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pure4j.collections.Cons Maven / Gradle / Ivy

There is a newer version: 0.3.1
Show newest version
/**
 *   Copyright (c) Rich Hickey. All rights reserved.
 *   The use and distribution terms for this software are covered by the
 *   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
 *   which can be found in the file epl-v10.html at the root of this distribution.
 *   By using this software in any fashion, you are agreeing to be bound by
 * 	 the terms of this license.
 *   You must not remove this notice, or any other, from this software.
 **/

/* rich Mar 25, 2006 11:01:29 AM */

package org.pure4j.collections;

import java.io.Serializable;

final public class Cons extends ASeq implements Serializable {

	private static final long serialVersionUID = -5751064091837549225L;
	private final K _first;
	private final ISeq _more;

	public Cons(K first, ISeq _more) {
		this._first = first;
		this._more = _more;
	}

	public K first() {
		return _first;
	}

	public ISeq next() {
		return more();
	}

	public ISeq more() {
		if (_more == null)
			return PersistentList.emptySeq();
		return _more;
	}

	public int count() {
		return 1 + PureCollections.count(_more);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy