diff --git a/.vscode/settings.json b/.vscode/settings.json index a4e4aba..3092ab3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "java.format.settings.url": "eclipse-formatter.xml", - "java.checkstyle.configuration": "${workspaceFolder}\\checkstyle.xml" + "editor.tokenColorCustomizations": { + "comments": "", + "textMateRules": [] + } } \ No newline at end of file diff --git a/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaCircular.java b/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaCircular.java index c09fc51..ed7a126 100644 --- a/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaCircular.java +++ b/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaCircular.java @@ -7,11 +7,11 @@ public ColaCircular(int capacidad) { @Override public Result insertar(T elemento) { - if (this.isFull()) { + if (this.isFull()) return new Result.ColaLlena(); - } + this.inner[cola] = elemento; - // `(9 + 1) % 10 => 0` + this.cola = (cola + 1) % capacidad; this.longitud++; return new Result.OK(); @@ -19,14 +19,12 @@ public Result insertar(T elemento) { @Override public Option quitar() { - if (this.isEmpty()) { + if (this.isEmpty()) return new Option.None<>(); - } T elemento = this.inner[frente]; inner[frente] = null; - // `(9 + 1) % 10 => 0` frente = (frente + 1) % capacidad; longitud--; return new Option.Some<>(elemento); diff --git a/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaSimple.java b/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaSimple.java index 95a75be..81ec928 100644 --- a/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaSimple.java +++ b/src/main/java/com/utp/clsEstructuraDatos/Estructuras/colas/ColaSimple.java @@ -14,7 +14,8 @@ public class ColaSimple extends AbstractCola { * puede insertar o quitar son `ColaSimple.capacidad` elementos *

* - * @param capacidad int + * @param capacidad + * int */ public ColaSimple(int capacidad) { super(capacidad); @@ -30,6 +31,7 @@ public Result insertar(T elemento) { return new Result.ColaLlena(); this.inner[cola] = elemento; + this.cola = (cola + 1) % capacidad; this.longitud++; return new Result.OK(); @@ -40,9 +42,9 @@ public Result insertar(T elemento) { */ @Override public Option quitar() { - if (this.isEmpty()) { + if (this.isEmpty()) return new Option.None<>(); - } + T elemento = this.inner[frente]; frente = (frente + 1) % capacidad; if (frente == cola)