diff options
author | Brian Vosburgh | 2015-07-17 21:28:04 +0000 |
---|---|---|
committer | Brian Vosburgh | 2015-07-17 21:28:04 +0000 |
commit | b921d62d585f55888f71e68ac75f6c56f1fea735 (patch) | |
tree | 6d99556a110cc9e24a5a542267f073109681415b /common/plugins/org.eclipse.jpt.common.utility/src/org | |
parent | b671990ca4154565a91a85217386360f20028c59 (diff) | |
download | webtools.dali-b921d62d585f55888f71e68ac75f6c56f1fea735.tar.gz webtools.dali-b921d62d585f55888f71e68ac75f6c56f1fea735.tar.xz webtools.dali-b921d62d585f55888f71e68ac75f6c56f1fea735.zip |
add Comparator constructor to PriorityQueue
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.utility/src/org')
-rw-r--r-- | common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/PriorityQueue.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/PriorityQueue.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/PriorityQueue.java index 98f5f9584b..fdc389dd2a 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/PriorityQueue.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/collection/PriorityQueue.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Oracle. All rights reserved. + * Copyright (c) 2013, 2015 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -10,13 +10,16 @@ package org.eclipse.jpt.common.utility.internal.collection; import java.io.Serializable; +import java.util.Comparator; import java.util.SortedSet; +import java.util.TreeSet; import org.eclipse.jpt.common.utility.collection.Queue; /** * Adapt a {@link SortedSet} to create a priority implementation of the * {@link Queue} interface. Elements will dequeue in the order determined by - * wrapped sorted set. + * wrapped sorted set (i.e. {@link #dequeue} will return the element returned + * by {@link SortedSet#first}. * @param <E> the type of elements maintained by the queue */ public class PriorityQueue<E> @@ -27,6 +30,16 @@ public class PriorityQueue<E> private static final long serialVersionUID = 1L; + /** + * Construct a priority queue that uses the specified comparator + * to determine the order elements will be dequeued + * (i.e. {@link #dequeue} will return the current element with + * the lowest position, as specified by the comparator). + */ + public PriorityQueue(Comparator<? super E> comparator) { + this(new TreeSet<E>(comparator)); + } + public PriorityQueue(SortedSet<E> elements) { super(); if (elements == null) { |