-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortedCyclist
More file actions
78 lines (67 loc) · 1.83 KB
/
SortedCyclist
File metadata and controls
78 lines (67 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package Generics;
import java.util.*;
import java.util.function.Predicate;
public class SortedCyclist<T extends Comparable<T>> {
private List<T> list=new ArrayList<>();
private int iterator=0;
public T next(){
T item = list.get(iterator);
iterator=iterator%list.size();
return item;
}
public void add(T value){
list.add(value);
Collections.sort(list);
}
public boolean contains(T value){
return list.contains(value);
}
public void remove(T value){
list.remove(value);
}
public void addAll(Collection<? extends T > collection){
list.addAll(collection);
Collections.sort(list);
}
public static <T> T findFirst(Predicate<T> pred,Collection<T> collection){
for(T item:collection){
if (pred.test(item)){
return item;
}
}
return null;
}
public static double[] co(int n){
double[] d=new double[n];
for(int i=0;i<n;i++){
d[i]=Math.pow(2,i);
}
return d;
}
public void tra(){
final int height = 5;
int width=height;
int triangle[][] = new int[height][];
for (int i = 0; i < height; i++) {
triangle[i]=new int[height-i];
for (int j = 0; j < height-i; j++) {
triangle[i][j]=i+j+1;
}
}
}
public static void s(String s){
int count=0;
int count_uc=0;
int count_lc=0;
Scanner scanner= new Scanner(System.in);
String text=scanner.nextLine();
for (int i=0;i<text.length();i++){
char c = text.charAt(i);
if (Character.isLowerCase(c)){
count_uc+=1;
}
if(scanner.hasNext(s.toUpperCase())){
}
}
}
}