Network implements Iterable<Neuron>,
               Serializable { public Collection<Neuron> getNeurons(Comparator<Neuron> comparator) { final List<Neuron> neurons = new ArrayList<Neuron>(); neurons.addAll(neuronMap.values()); Collections.sort(neurons, comparator); return neurons; } Network(long nextId,
            int featureSize,
            Neuron[] neuronList,
            long[][] neighbourIdList);  Network(long initialIdentifier,
                   int featureSize); Iterator<Neuron> iterator(); Collection<Neuron> getNeurons(Comparator<Neuron> comparator); long createNeuron(double[] features); void deleteNeuron(Neuron neuron); int getFeaturesSize(); void addLink(Neuron a,
                        Neuron b); void deleteLink(Neuron a,
                           Neuron b); Neuron getNeuron(long id); Collection<Neuron> getNeighbours(Iterable<Neuron> neurons); Collection<Neuron> getNeighbours(Iterable<Neuron> neurons,
                                            Iterable<Neuron> exclude); Collection<Neuron> getNeighbours(Neuron neuron); Collection<Neuron> getNeighbours(Neuron neuron,
                                            Iterable<Neuron> exclude);  }
@Test public void testIterationOrder() { final FeatureInitializer[] initArray = { init }; final Network net = new NeuronSquareMesh2D(4, false, 3, true, SquareNeighbourhood.VON_NEUMANN, initArray).getNetwork(); boolean isUnspecifiedOrder = false; long previousId = Long.MIN_VALUE; for (Neuron n : net.getNeurons(new Network.NeuronIdentifierComparator())) { final long currentId = n.getIdentifier(); if (currentId < previousId) { isUnspecifiedOrder = true; break; } previousId = currentId; } Assert.assertFalse(isUnspecifiedOrder); }