From 150d41e1a5a7c905ca6c5102989c5acfea3b7b32 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Thu, 23 Nov 2023 21:05:32 +0400 Subject: [PATCH 1/5] lab4 without additional task --- .idea/.name | 1 - src/Main.java | 10 +- src/frames/FrameShipsCollection.java | 126 +++++++++++++++++++---- src/generics/SetGeneric.java | 36 +++---- src/generics/ShipsGenericCollection.java | 21 ++-- src/generics/ShipsGenericStorage.java | 39 +++++++ 6 files changed, 177 insertions(+), 56 deletions(-) delete mode 100644 .idea/.name create mode 100644 src/generics/ShipsGenericStorage.java diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 002da1d..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Main.java \ No newline at end of file diff --git a/src/Main.java b/src/Main.java index da3b21a..c88725c 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,9 +1,7 @@ -import frames.FrameBattleship; -import frames.FrameShipsCollection; -import frames.HardFrame; - -import java.io.IOException; +import frames.*; public class Main { - public static void main(String[] args) throws IOException { new HardFrame(); } + public static void main(String[] args){ + new FrameShipsCollection(); + } } diff --git a/src/frames/FrameShipsCollection.java b/src/frames/FrameShipsCollection.java index 93fa372..f2b7393 100644 --- a/src/frames/FrameShipsCollection.java +++ b/src/frames/FrameShipsCollection.java @@ -1,23 +1,29 @@ package frames; import javax.swing.*; +import javax.swing.border.StrokeBorder; import java.awt.*; import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; import drawing_objects.DrawingShip; -import generics.ShipsGenericCollection; -import movement_strategy.DrawingObjectShip; +import generics.ShipsGenericStorage; public class FrameShipsCollection extends JFrame { - private ShipsGenericCollection ships; - JComponent pictureBoxCollection; - TextField textFieldNumber; + private final ShipsGenericStorage storage; + private JComponent pictureBoxCollection; + private TextField textFieldNumber; + private TextField textFieldStorageName; + private JList listStorages; + private DefaultListModel listModel; public FrameShipsCollection(){ super("Набор кораблей"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); createGui(); - ships = new ShipsGenericCollection<>(pictureBoxCollection.getWidth(), pictureBoxCollection.getHeight()); + pack(); setVisible(true); + storage = new ShipsGenericStorage(pictureBoxCollection.getWidth(), pictureBoxCollection.getHeight()); } private void createGui(){ //components initialisation @@ -25,7 +31,12 @@ public class FrameShipsCollection extends JFrame { public void paintComponent(Graphics graphics){ super.paintComponent(graphics); Graphics2D graphics2D = (Graphics2D) graphics; - if (ships != null) ships.showShips(graphics2D); + if (listStorages == null || storage == null) + return; + var collection = storage.getSet(listStorages.getSelectedValue()); + if (collection == null) + return; + collection.showShips(graphics2D); super.repaint(); } }; @@ -34,34 +45,101 @@ public class FrameShipsCollection extends JFrame { textFieldNumber = new TextField(); JButton buttonRemoveShip = new JButton("Удалить корабль"); JButton buttonRefreshCollection = new JButton("Обновить коллекцию"); + JButton buttonAddSet = new JButton("Добавить набор"); + JButton buttonDeleteSet = new JButton("Удалить набор"); + textFieldStorageName = new TextField(); + listModel = new DefaultListModel<>(); + JScrollPane scrollPane = new JScrollPane(); + listStorages= new JList<>(listModel); + scrollPane.setViewportView(listStorages); //ActionListeners and ActionCommand addition + buttonAddSet.addActionListener(e -> buttonAddSet_Click()); + buttonDeleteSet.addActionListener(e -> buttonDeleteSet_Click()); buttonAddShip.addActionListener(e -> buttonAddShipClick()); buttonRemoveShip.addActionListener(e -> buttonRemoveShipClick()); buttonRefreshCollection.addActionListener(e -> buttonRefreshCollectionClick()); - //addition to frame - JPanel panelCollection = new JPanel(new GridBagLayout()); + //panels and constraints initialisation + JPanel panelTools = new JPanel(new GridBagLayout()); + panelTools.setBorder(new StrokeBorder(new BasicStroke(3))); + panelTools.setToolTipText("Инструменты"); + JPanel panelSets = new JPanel(new GridBagLayout()); + panelSets.setBorder(new StrokeBorder(new BasicStroke(3))); + panelSets.setToolTipText("Наборы"); GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets.left = constraints.insets.right = 2; - constraints.insets.top = constraints.insets.bottom = 25; + constraints.insets.left = constraints.insets.right = 5; + constraints.insets.top = constraints.insets.bottom = 5; constraints.fill = GridBagConstraints.BOTH; + //addition to panelSets constraints.gridx = 0; constraints.gridy = 0; - panelCollection.add(buttonAddShip, constraints); + panelSets.add(textFieldStorageName, constraints); constraints.gridx = 0; constraints.gridy = 1; - panelCollection.add(textFieldNumber, constraints); + panelSets.add(buttonAddSet, constraints); constraints.gridx = 0; constraints.gridy = 2; - panelCollection.add(buttonRemoveShip, constraints); + panelSets.add(scrollPane, constraints); constraints.gridx = 0; constraints.gridy = 3; - panelCollection.add(buttonRefreshCollection, constraints); + panelSets.add(buttonDeleteSet, constraints); + //addition to panelTools + constraints.gridx = 0; + constraints.gridy = 0; + panelTools.add(panelSets, constraints); + constraints.gridx = 0; + constraints.gridy = 1; + panelTools.add(buttonAddShip, constraints); + constraints.gridx = 0; + constraints.gridy = 2; + panelTools.add(textFieldNumber, constraints); + constraints.gridx = 0; + constraints.gridy = 3; + panelTools.add(buttonRemoveShip, constraints); + constraints.gridx = 0; + constraints.gridy = 4; + panelTools.add(buttonRefreshCollection, constraints); + //addition to frame setLayout(new BorderLayout()); - add(panelCollection, BorderLayout.EAST); + add(panelTools, BorderLayout.EAST); add(pictureBoxCollection, BorderLayout.CENTER); - pack(); + } + private void reloadObjects(){ + int index = listStorages.getSelectedIndex(); + listModel.clear(); + ArrayList keys = storage.getKeys(); + for (String key : keys) { + listModel.addElement(key); + } + if(listModel.size() > 0 && (index == -1 || index >= listModel.size())) + listStorages.setSelectedIndex(0); + else if(listModel.size() > 0) + listStorages.setSelectedIndex(index); + } + public void buttonAddSet_Click() { + if(textFieldStorageName.getText() == null ) { + JOptionPane.showMessageDialog(this, "Не все данные заполнены"); + return; + } + String name = textFieldStorageName.getText(); + if (Objects.equals(name, "")) { + JOptionPane.showMessageDialog(this, "Не все данные заполнены"); + return; + } + storage.addSet(name); + reloadObjects(); + } + public void buttonDeleteSet_Click() { + if (listStorages.getSelectedIndex() == -1) + return; + storage.delSet(listStorages.getSelectedValue()); + reloadObjects(); } private void buttonAddShipClick() { + if (listStorages.getSelectedIndex() == -1) + return; + var obj = storage.getSet(listStorages.getSelectedValue()); + if (obj == null) + return; FrameBattleship form; try { form = new FrameBattleship(); @@ -72,7 +150,8 @@ public class FrameShipsCollection extends JFrame { form.select(); DrawingShip ship = form.getSelectedShip(); form.dispose(); - if (ships.insert(ship)) { + if (ship != null && obj.insert(ship)) { + System.out.println(ship.getWidth() + " " + ship.getHeight() + " " + ship.getPosX() + " " + ship.getPosY()); JOptionPane.showMessageDialog(this, "Объект добавлен"); pictureBoxCollection.repaint(); } @@ -82,8 +161,13 @@ public class FrameShipsCollection extends JFrame { }); } private void buttonRemoveShipClick(){ + if (listStorages.getSelectedIndex() == -1) + return; + var obj = storage.getSet(listStorages.getSelectedValue()); + if (obj == null) + return; int pos = Integer.parseInt(textFieldNumber.getText()); - if (ships.remove(pos)){ + if (storage.getSet(listStorages.getSelectedValue()).remove(pos)){ JOptionPane.showMessageDialog(this, "Объект удален"); pictureBoxCollection.repaint(); } @@ -91,5 +175,7 @@ public class FrameShipsCollection extends JFrame { JOptionPane.showMessageDialog(this, "Не удалось удалить объект"); } } - private void buttonRefreshCollectionClick(){pictureBoxCollection.repaint();} + private void buttonRefreshCollectionClick(){ + pictureBoxCollection.repaint(); + } } diff --git a/src/generics/SetGeneric.java b/src/generics/SetGeneric.java index 9976170..0e90f12 100644 --- a/src/generics/SetGeneric.java +++ b/src/generics/SetGeneric.java @@ -1,41 +1,35 @@ package generics; -import java.lang.reflect.Array; +import java.util.ArrayList; public class SetGeneric{ - private final T[] places; - public int getCount() {return places.length;} - public SetGeneric(int count, Class type){ - places = (T[]) Array.newInstance(type, count); + private final ArrayList places; + public int getCount() {return places.size();} + private final int maxCount; + public SetGeneric(int count){ + maxCount = count; + places = new ArrayList<>(); } public boolean insert(T ship){ + if(places.size() == maxCount) + return false; return insert(ship, 0); } public boolean insert(T ship, int position){ - if (!(position >= 0 && position < places.length)) + if (!(position >= 0 && position <= places.size() && places.size() < maxCount)) return false; - if (places[position] != null) - { - int ind = position; - while (ind < places.length && places[ind] != null) - ind++; - if (ind == places.length) - return false; - for (int i = ind - 1; i >= position; i--) - places[i + 1] = places[i]; - } - places[position] = ship; + places.add(position, ship); return true; } public boolean remove(int position){ - if(!(position >= 0 && position < getCount())) + if(!(position >= 0 && position < places.size())) return false; - places[position] = null; + places.remove(position); return true; } public T get(int position){ - if(!(position >= 0 && position < getCount())) + if(!(position >= 0 && position < places.size())) return null; - return places[position]; + return places.get(position); } } \ No newline at end of file diff --git a/src/generics/ShipsGenericCollection.java b/src/generics/ShipsGenericCollection.java index a4cda0f..ab82ed1 100644 --- a/src/generics/ShipsGenericCollection.java +++ b/src/generics/ShipsGenericCollection.java @@ -6,17 +6,20 @@ import movement_strategy.*; import java.awt.*; public class ShipsGenericCollection{ - private int pictureWidth; - private int pictureHeight; + private final int pictureWidth; + private final int pictureHeight; private final int placeSizeWidth = 220; private final int placeSizeHeight = 60; - private SetGeneric collection; + private final SetGeneric collection; + public int getCount(){ + return collection.getCount(); + } public ShipsGenericCollection(int picWidth, int picHeight){ int width = picWidth / placeSizeWidth; int height = picHeight / placeSizeHeight; pictureWidth = picWidth; pictureHeight = picHeight; - collection = new SetGeneric(width * height, (Class) DrawingShip.class); + collection = new SetGeneric<>(width * height); } public boolean insert ( T obj) { if (obj != null) @@ -24,16 +27,18 @@ public class ShipsGenericCollection= collection.getCount()) + return null; + return collection.get(position); + } public void showShips(Graphics2D graphics2D){ DrawBackground(graphics2D); DrawObjects(graphics2D); diff --git a/src/generics/ShipsGenericStorage.java b/src/generics/ShipsGenericStorage.java new file mode 100644 index 0000000..dceae6c --- /dev/null +++ b/src/generics/ShipsGenericStorage.java @@ -0,0 +1,39 @@ +package generics; + +import drawing_objects.DrawingShip; +import movement_strategy.DrawingObjectShip; + +import java.util.ArrayList; +import java.util.HashMap; + +public class ShipsGenericStorage { + private final int pictureWidth; + private final int pictureHeight; + final HashMap> shipsStorages; + public ShipsGenericStorage(int pictureWidth, int pictureHeight){ + shipsStorages = new HashMap<>(); + this.pictureWidth = pictureWidth; + this.pictureHeight = pictureHeight; + } + public ArrayList getKeys(){ + return new ArrayList<>(shipsStorages.keySet()); + } + public void addSet(String name){ + if(shipsStorages.containsKey(name)) + return; + shipsStorages.put(name, new ShipsGenericCollection<>(pictureWidth, pictureHeight)); + } + public void delSet(String name){ + if(!shipsStorages.containsKey(name)) + return; + shipsStorages.remove(name); + } + public ShipsGenericCollection getSet(String name){ + if(!shipsStorages.containsKey(name)) + return null; + return shipsStorages.get(name); + } + public DrawingShip getShip(String collectionName, int position){ + return shipsStorages.get(collectionName).get(position); + } +} -- 2.25.1 From c526d2cfc18b07088e89cdab0bb0cd6177445053 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Thu, 23 Nov 2023 22:47:50 +0400 Subject: [PATCH 2/5] lab4 with additional task --- src/frames/FrameBattleship.java | 9 +++++++- src/frames/FrameShipsCollection.java | 27 ++++++++++++++++++++---- src/generics/ShipsGenericCollection.java | 2 +- src/generics/TrashCollection.java | 21 ++++++++++++++++++ 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 src/generics/TrashCollection.java diff --git a/src/frames/FrameBattleship.java b/src/frames/FrameBattleship.java index d285489..9793ab7 100644 --- a/src/frames/FrameBattleship.java +++ b/src/frames/FrameBattleship.java @@ -28,7 +28,7 @@ public class FrameBattleship extends JFrame { public FrameBattleship() throws IOException { super("Линкор"); setSize(new Dimension(900,500)); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //components initialisation pictureBoxBattleship = new JComponent(){ public void paintComponent(Graphics graphics){ @@ -184,4 +184,11 @@ public class FrameBattleship extends JFrame { } selectedShip = drawingShip; } + public void setShip(DrawingShip ship){ + ship.setPosition(0,0); + drawingShip = ship; + pictureBoxBattleship.setBounds(0,0,getContentPane().getWidth(),getContentPane().getHeight()); + drawingShip.drawTransport((Graphics2D) pictureBoxBattleship.getGraphics()); + draw(); + } } \ No newline at end of file diff --git a/src/frames/FrameShipsCollection.java b/src/frames/FrameShipsCollection.java index f2b7393..28d4717 100644 --- a/src/frames/FrameShipsCollection.java +++ b/src/frames/FrameShipsCollection.java @@ -9,9 +9,11 @@ import java.util.Objects; import drawing_objects.DrawingShip; import generics.ShipsGenericStorage; +import generics.TrashCollection; public class FrameShipsCollection extends JFrame { private final ShipsGenericStorage storage; + TrashCollection trashCollection = new TrashCollection<>(); private JComponent pictureBoxCollection; private TextField textFieldNumber; private TextField textFieldStorageName; @@ -47,6 +49,7 @@ public class FrameShipsCollection extends JFrame { JButton buttonRefreshCollection = new JButton("Обновить коллекцию"); JButton buttonAddSet = new JButton("Добавить набор"); JButton buttonDeleteSet = new JButton("Удалить набор"); + JButton buttonTrash = new JButton("Корзина"); textFieldStorageName = new TextField(); listModel = new DefaultListModel<>(); JScrollPane scrollPane = new JScrollPane(); @@ -58,6 +61,7 @@ public class FrameShipsCollection extends JFrame { buttonAddShip.addActionListener(e -> buttonAddShipClick()); buttonRemoveShip.addActionListener(e -> buttonRemoveShipClick()); buttonRefreshCollection.addActionListener(e -> buttonRefreshCollectionClick()); + buttonTrash.addActionListener(e -> buttonTrashClick()); //panels and constraints initialisation JPanel panelTools = new JPanel(new GridBagLayout()); panelTools.setBorder(new StrokeBorder(new BasicStroke(3))); @@ -98,6 +102,9 @@ public class FrameShipsCollection extends JFrame { constraints.gridx = 0; constraints.gridy = 4; panelTools.add(buttonRefreshCollection, constraints); + constraints.gridx = 0; + constraints.gridy = 5; + panelTools.add(buttonTrash, constraints); //addition to frame setLayout(new BorderLayout()); add(panelTools, BorderLayout.EAST); @@ -115,7 +122,7 @@ public class FrameShipsCollection extends JFrame { else if(listModel.size() > 0) listStorages.setSelectedIndex(index); } - public void buttonAddSet_Click() { + private void buttonAddSet_Click() { if(textFieldStorageName.getText() == null ) { JOptionPane.showMessageDialog(this, "Не все данные заполнены"); return; @@ -128,7 +135,7 @@ public class FrameShipsCollection extends JFrame { storage.addSet(name); reloadObjects(); } - public void buttonDeleteSet_Click() { + private void buttonDeleteSet_Click() { if (listStorages.getSelectedIndex() == -1) return; storage.delSet(listStorages.getSelectedValue()); @@ -151,7 +158,6 @@ public class FrameShipsCollection extends JFrame { DrawingShip ship = form.getSelectedShip(); form.dispose(); if (ship != null && obj.insert(ship)) { - System.out.println(ship.getWidth() + " " + ship.getHeight() + " " + ship.getPosX() + " " + ship.getPosY()); JOptionPane.showMessageDialog(this, "Объект добавлен"); pictureBoxCollection.repaint(); } @@ -167,8 +173,10 @@ public class FrameShipsCollection extends JFrame { if (obj == null) return; int pos = Integer.parseInt(textFieldNumber.getText()); - if (storage.getSet(listStorages.getSelectedValue()).remove(pos)){ + var ship = obj.get(pos); + if (obj.remove(pos)){ JOptionPane.showMessageDialog(this, "Объект удален"); + trashCollection.add(ship); pictureBoxCollection.repaint(); } else{ @@ -178,4 +186,15 @@ public class FrameShipsCollection extends JFrame { private void buttonRefreshCollectionClick(){ pictureBoxCollection.repaint(); } + private void buttonTrashClick(){ + if(trashCollection.getSize() == 0) + return; + FrameBattleship form; + try { + form = new FrameBattleship(); + } catch (IOException e) { + throw new RuntimeException(e); + } + form.setShip(trashCollection.pop()); + } } diff --git a/src/generics/ShipsGenericCollection.java b/src/generics/ShipsGenericCollection.java index ab82ed1..4806eab 100644 --- a/src/generics/ShipsGenericCollection.java +++ b/src/generics/ShipsGenericCollection.java @@ -61,7 +61,7 @@ public class ShipsGenericCollection { + LinkedList list; + public TrashCollection(){ + list = new LinkedList<>(); + } + public int getSize(){ + return list.size(); + } + public void add(T ship){ + list.add(ship); + } + public T pop(){ + if(list.size() == 0) + return null; + return list.pop(); + } +} -- 2.25.1 From d210db6966851051c4ffb3ce19e6d6de41912788 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Fri, 24 Nov 2023 10:03:45 +0400 Subject: [PATCH 3/5] lab4 some minor fixes --- src/frames/FrameShipsCollection.java | 9 +++++---- src/generics/TrashCollection.java | 21 --------------------- 2 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 src/generics/TrashCollection.java diff --git a/src/frames/FrameShipsCollection.java b/src/frames/FrameShipsCollection.java index 28d4717..e0b4678 100644 --- a/src/frames/FrameShipsCollection.java +++ b/src/frames/FrameShipsCollection.java @@ -5,15 +5,15 @@ import javax.swing.border.StrokeBorder; import java.awt.*; import java.io.IOException; import java.util.ArrayList; +import java.util.LinkedList; import java.util.Objects; import drawing_objects.DrawingShip; import generics.ShipsGenericStorage; -import generics.TrashCollection; public class FrameShipsCollection extends JFrame { private final ShipsGenericStorage storage; - TrashCollection trashCollection = new TrashCollection<>(); + LinkedList trashCollection = new LinkedList<>(); private JComponent pictureBoxCollection; private TextField textFieldNumber; private TextField textFieldStorageName; @@ -45,6 +45,7 @@ public class FrameShipsCollection extends JFrame { pictureBoxCollection.setPreferredSize(new Dimension(700, 450)); JButton buttonAddShip = new JButton("Добавить корабль"); textFieldNumber = new TextField(); + textFieldNumber.setText("0"); JButton buttonRemoveShip = new JButton("Удалить корабль"); JButton buttonRefreshCollection = new JButton("Обновить коллекцию"); JButton buttonAddSet = new JButton("Добавить набор"); @@ -167,7 +168,7 @@ public class FrameShipsCollection extends JFrame { }); } private void buttonRemoveShipClick(){ - if (listStorages.getSelectedIndex() == -1) + if (listStorages.getSelectedIndex() == -1 || Objects.equals(textFieldNumber.getText(), "") || textFieldNumber.getText() == null) return; var obj = storage.getSet(listStorages.getSelectedValue()); if (obj == null) @@ -187,7 +188,7 @@ public class FrameShipsCollection extends JFrame { pictureBoxCollection.repaint(); } private void buttonTrashClick(){ - if(trashCollection.getSize() == 0) + if(trashCollection.peek() == null) return; FrameBattleship form; try { diff --git a/src/generics/TrashCollection.java b/src/generics/TrashCollection.java deleted file mode 100644 index 52373d7..0000000 --- a/src/generics/TrashCollection.java +++ /dev/null @@ -1,21 +0,0 @@ -package generics; - -import java.util.LinkedList; - -public class TrashCollection { - LinkedList list; - public TrashCollection(){ - list = new LinkedList<>(); - } - public int getSize(){ - return list.size(); - } - public void add(T ship){ - list.add(ship); - } - public T pop(){ - if(list.size() == 0) - return null; - return list.pop(); - } -} -- 2.25.1 From 22c6e38b9215512671328ecbecd4f9e086ea0a67 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Fri, 24 Nov 2023 10:14:49 +0400 Subject: [PATCH 4/5] lab4 some minor fixes --- src/frames/FrameShipsCollection.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frames/FrameShipsCollection.java b/src/frames/FrameShipsCollection.java index e0b4678..bf5bd1c 100644 --- a/src/frames/FrameShipsCollection.java +++ b/src/frames/FrameShipsCollection.java @@ -188,7 +188,8 @@ public class FrameShipsCollection extends JFrame { pictureBoxCollection.repaint(); } private void buttonTrashClick(){ - if(trashCollection.peek() == null) + DrawingShip ship = trashCollection.pop(); + if(ship == null) return; FrameBattleship form; try { @@ -196,6 +197,6 @@ public class FrameShipsCollection extends JFrame { } catch (IOException e) { throw new RuntimeException(e); } - form.setShip(trashCollection.pop()); + form.setShip(ship); } } -- 2.25.1 From 234aa190c86e0a196d20c6eb70a61a0f87abac54 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Fri, 24 Nov 2023 10:19:26 +0400 Subject: [PATCH 5/5] lab4 some minor fixes --- src/frames/FrameShipsCollection.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/frames/FrameShipsCollection.java b/src/frames/FrameShipsCollection.java index bf5bd1c..9e78344 100644 --- a/src/frames/FrameShipsCollection.java +++ b/src/frames/FrameShipsCollection.java @@ -188,8 +188,7 @@ public class FrameShipsCollection extends JFrame { pictureBoxCollection.repaint(); } private void buttonTrashClick(){ - DrawingShip ship = trashCollection.pop(); - if(ship == null) + if (trashCollection.size() == 0) return; FrameBattleship form; try { @@ -197,6 +196,6 @@ public class FrameShipsCollection extends JFrame { } catch (IOException e) { throw new RuntimeException(e); } - form.setShip(ship); + form.setShip(trashCollection.pop()); } } -- 2.25.1