aufgeräumt
This commit is contained in:
parent
7665f9bbb6
commit
2ee19fc746
|
@ -19,10 +19,6 @@ public class CharCollection implements Cloneable{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharCollection(List<Character> list) {
|
|
||||||
this.list = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return this.list.size();
|
return this.list.size();
|
||||||
}
|
}
|
||||||
|
@ -40,24 +36,6 @@ public class CharCollection implements Cloneable{
|
||||||
return set.size();
|
return set.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public char top() {
|
|
||||||
if(list.size() == 0) return 0;
|
|
||||||
ArrayList<Character> test = new ArrayList<>(list);
|
|
||||||
Collections.sort(test);
|
|
||||||
int actual=0, most=0;
|
|
||||||
char top = test.get(0);
|
|
||||||
for(char c : test) {
|
|
||||||
if (top == c) {
|
|
||||||
actual++;
|
|
||||||
if (actual >= most) most = actual; top = c;
|
|
||||||
} else {
|
|
||||||
actual = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return top;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public char top() {
|
public char top() {
|
||||||
if(list.isEmpty()) return 0;
|
if(list.isEmpty()) return 0;
|
||||||
int max = 0;
|
int max = 0;
|
||||||
|
@ -98,7 +76,6 @@ public class CharCollection implements Cloneable{
|
||||||
if(removeCharacterOnce) i--;
|
if(removeCharacterOnce) i--;
|
||||||
removeCharacterOnce = false;
|
removeCharacterOnce = false;
|
||||||
}
|
}
|
||||||
//System.out.println("list2: "+list2.toString());
|
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
for(char c:list) s.append(c);
|
for(char c:list) s.append(c);
|
||||||
return new CharCollection(s.toString());
|
return new CharCollection(s.toString());
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class CharCollectionTest {
|
||||||
assertEquals(5, new CharCollection("Hallo").size());
|
assertEquals(5, new CharCollection("Hallo").size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void count() {
|
public void count() {
|
||||||
assertEquals(2, new CharCollection("Hallo").count('l'));
|
assertEquals(2, new CharCollection("Hallo").count('l'));
|
||||||
|
|
Loading…
Reference in New Issue