Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static<T> boolean isThere(Queue<T> queue , T a )
- {
- while(!queue.isEmpty())
- {
- if(a == queue.head())
- return true;
- else
- queue.remove();
- }
- return false;
- }
- public static Queue<Integer> createIntQueue()
- {
- Queue<Integer> queue = new Queue<Integer>();
- System.out.println("Enter first value for queue");
- int temp = UI.nextInt();
- while(temp != 999)
- {
- queue.insert(temp);
- System.out.println("Enter next value (999 to stop)");
- temp = UI.nextInt();
- }
- return queue;
- }
- public static<T> Queue<T> duplicate(Queue<T> queue)
- {
- Queue<T> duplicate = new Queue<T>();
- Queue<T> temp = new Queue<T>();
- while(!queue.isEmpty())
- {
- duplicate.insert(queue.head());
- temp.insert(queue.remove());
- }
- while(!temp.isEmpty())
- queue.insert(temp.remove());
- return duplicate;
- }
- public static Queue<Integer> count(Queue<Integer> Q)
- {
- }
- public static Queue<Integer> Q_By_Appearance(Queue<Integer> Q)
- {
- int temp;
- Queue<Integer> Q2 = duplicate(Q);
- Queue<Integer> Qapp = new Queue<Integer>();
- while(!Q2.isEmpty())
- {
- temp = Q2.head();
- Qapp.insert(temp);
- }
- }
- public static int sumQueue(Queue<Integer> Q)
- {
- int sum = 0;
- while(!Q.isEmpty())
- {
- sum += Q.remove();
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement