Conversation
| int deleteCounter = 0; | ||
| for (Integer i : this.array) { | ||
| if (valueOccurs(toDelete, i) == true) { | ||
| continue; |
There was a problem hiding this comment.
something seems off about the names here. I don't quite get why you continue if a value occurs. On top of that you can simply use
if (valueOccurs(toDelete, i) without the == true. by default an if statement is looking for a true statement.
There was a problem hiding this comment.
ok I get whats going on now. you're checking if its a value that has already been set to be deleted. this block is just a bit confusing. Need better names for variables.
| return counter; | ||
| } | ||
|
|
||
| public static boolean valueOccurs(Integer[] inputArray, int value) { |
There was a problem hiding this comment.
if you're pulling the value from the array you are checking, then it seems like this in your program is always going to be returning true. Is that correct?
There was a problem hiding this comment.
I got what is going on here. This fine, but I would name the method something more like isValueInArray and order the arguments (int valueToCheckFor, Integer[] arrayToSearchThrough)
| int counter = 0; | ||
| for (int i = 0; i < revisedArray.length; i++) { | ||
| if (!revisedArray[i].equals(value)) { | ||
| outputArray = Arrays.copyOf(outputArray, outputArray.length + 1); |
There was a problem hiding this comment.
it would be less memory intensive if you figured out first how many spaces you'd need in your outputArray before inserting values. This way you don't have to create a copy every single time.
| * Created by leon on 1/28/18. | ||
| * @ATTENTION_TO_STUDENTS You are forbidden from modifying the signature of this class. | ||
| */ | ||
| public final class StringDuplicateDeleter extends DuplicateDeleter<String> { |
There was a problem hiding this comment.
looks like this class is mostly the same as Integer deleter. My feedback is pretty much the same.
| public static int timesValueOccurs(String[] inputArray, String word) { | ||
| int counter = 0; | ||
| for (String x : inputArray) { | ||
| if (x == word) { |
There was a problem hiding this comment.
== is not correct for strings. Use word.equals
|
|
||
| public static boolean valueOccurs(String[] inputArray, String word) { | ||
| for (String x : inputArray) { | ||
| if (x == word) { |
There was a problem hiding this comment.
== is not correct for strings. Use word.equals
No description provided.