001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      https://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.collections4;
019
020import java.util.Collection;
021import java.util.Comparator;
022
023/**
024 * Defines a type of {@code Bag} that maintains a sorted order among its unique representative members.
025 * <p>
026 * The {@link SortedMultiSet} interface provides the same functionality while complying with the {@link Collection Collection} contract, and should be preferred
027 * for new code; see the {@link Bag} documentation for migration notes.
028 * </p>
029 *
030 * @param <E> The type of elements in this bag.
031 * @see SortedMultiSet
032 * @since 2.0
033 * @deprecated Since 4.6.0, use {@link SortedMultiSet} instead; see the {@link Bag} Javadoc for migration notes.
034 */
035@Deprecated
036public interface SortedBag<E> extends Bag<E> {
037
038    /**
039     * Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
040     *
041     * @return The comparator in use, or null if natural ordering.
042     */
043    Comparator<? super E> comparator();
044
045    /**
046     * Returns the first (lowest) member.
047     *
048     * @return The first element in the sorted bag.
049     */
050    E first();
051
052    /**
053     * Returns the last (highest) member.
054     *
055     * @return The last element in the sorted bag.
056     */
057    E last();
058}