Skip to content

Instantly share code, notes, and snippets.

@Unihedro
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Unihedro/6a7827460eab2f826246 to your computer and use it in GitHub Desktop.
Save Unihedro/6a7827460eab2f826246 to your computer and use it in GitHub Desktop.
scrap
// ////////////////////////////////////////////////////////////
//
// The API and implementation of Fancy-Collectors, a library
// that implements Collectors for various tasks. Also provides
// a set of primitive Collectors as well as wrapper Stream
// implementations to use them as well as makes it easy for
// users to build their own collectors.
// Copyright (C) 2015 Unihedron 0
//
// This software (The source code, executables compiled from the
// source and attached documentation files within the repository)
// is dual licensed under:
// - The GNU General Public License (GPL) version 2.0; and
// - The Apache Software License (ASL) Version 2.0.
//
// You must use this file in compliance with either of the licenses
// listed above, that is, to acknowledge either of:
//
// 1) 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.
//
// 2A) This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 2B) This program is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// or the Apache Software License along with this program; If not,
// get your free copies at your own bandwidth expenses here:
// - GPL 2.0: http://www.gnu.org/licenses/gpl-2.0.txt
// - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
// ////////////////////////////////////////////////////////////
package com.unihedro.stream;
import java.util.Set;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector.Characteristics;
/**
* Base interface of primitive collectors, which are yadity yah too lazy to
* document all this just yet
*
* @author Unihedron&lt;<a href="mailto:unihedron@unihedro.com"
* >unihedron@unihedro.com</a>&gt;
*/
interface BaseCollector<T, A, R, V> {
Supplier<A> supplier();
R accumulator();
BinaryOperator<A> combiner();
Function<A, V> finisher();
Set<Characteristics> characteristics();
}
// ////////////////////////////////////////////////////////////
//
// The API and implementation of Fancy-Collectors, a library
// that implements Collectors for various tasks. Also provides
// a set of primitive Collectors as well as wrapper Stream
// implementations to use them as well as makes it easy for
// users to build their own collectors.
// Copyright (C) 2015 Unihedron 0
//
// This software (The source code, executables compiled from the
// source and attached documentation files within the repository)
// is dual licensed under:
// - The GNU General Public License (GPL) version 2.0; and
// - The Apache Software License (ASL) Version 2.0.
//
// You must use this file in compliance with either of the licenses
// listed above, that is, to acknowledge either of:
//
// 1) 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.
//
// 2A) This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 2B) This program is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// or the Apache Software License along with this program; If not,
// get your free copies at your own bandwidth expenses here:
// - GPL 2.0: http://www.gnu.org/licenses/gpl-2.0.txt
// - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0
//
// ////////////////////////////////////////////////////////////
package com.unihedro.stream;
import java.util.function.ObjIntConsumer;
import java.util.stream.Collector;
/**
* A primitive {@code int} version of {@link Collector}. Implementations of this
* interface can be used in {@link CollectibleIntStream#collect(IntCollector)}.
*
* @see Collector
* @see CollectibleIntStream#collect(IntCollector)
*
* @author Unihedron&lt;<a href="mailto:unihedron@unihedro.com"
* >unihedron@unihedro.com</a>&gt;
*/
public interface IntCollector<A, V>
extends BaseCollector<Integer, A, ObjIntConsumer<A>, V> {
// I am so lazy.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment