0
パフォーマンスベンチマークのためにScalaでGuava synchronizedQueueを初期化しようとしています。エラーのScalaのGoogle Guava synchronizedQueue初期化エラー
identifier expected but '[' found.
出典::。[INT]一部
class TestSynchronizedQueueJavaPTS {
private var assignedQForTest : java.util.Queue[Int] = null;
private var syncQueue : java.util.Queue[Int] = null;
def create(DS_Type : String) : java.util.concurrent.ConcurrentLinkedQueue[Int] ={
DS_Type match{
case "syncQueue" =>
syncQueue = com.google.common.collect.Queues.synchronizedQueue(com.google.common.collect.MinMaxPriorityQueue.[Int]create());
assignedQForTest = syncQueue;
}
assignedQForTest
}
}
は、しかし、私はこのエラーを取得しています。
import java.util.Queue;
import com.google.common.collect.MinMaxPriorityQueue;
import com.google.common.collect.Queues;
public class test {
public static void main(String[] args) {
Queue<Integer> queue = Queues.synchronizedQueue(MinMaxPriorityQueue.<Integer>create());
queue.add(15);
queue.add(63);
queue.add(20);
System.out.println (queue.poll());
System.out.println (queue.poll());
}
}
ソルツ、動作しません。次のエラーが返されます: '◾typearguments [Int]は、valueのオーバーロードされた代替のどれにも合致しないcreate:[E <:Comparable [E]](x $ 1:Iterable [_ <:E])com .common.collect.MinMaxPriorityQueue [E] [E <:Comparable [E]] com.google.common.collect.MinMaxPriorityQueue [E] オーバーロードされたメソッド値の型パラメータの数が[ <:Comparable [E]](x $ 1:Iterable [_ <:E])com.google.common.collect.MinMaxPriorityQueue [E] [E <:Comparable [E]]()com.google.common.collect .MinMaxPriorityQueue [E] ' –
Pranay
つまり、構文上の誤りです。 – Pranay
@Pranayあなたは私が言及した2番目の変更をしませんでした。「Int」を「Integer」に変更しました。また、私は 'Queue'を返すだけです。コードをコピー/ペーストしてチェックアウトするだけです – david