2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2014-02-19 06:26:43 +01:00
|
|
|
package appeng.me;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class NetworkList implements Collection<Grid>
|
|
|
|
{
|
|
|
|
|
2014-09-28 22:20:14 +02:00
|
|
|
private List<Grid> networks = new LinkedList<Grid>();
|
2014-02-19 06:26:43 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean add(Grid e)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.copy();
|
|
|
|
return this.networks.add( e );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean addAll(Collection<? extends Grid> c)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.copy();
|
|
|
|
return this.networks.addAll( c );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void clear()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.networks = new LinkedList<Grid>();
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean contains(Object o)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.networks.contains( o );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean containsAll(Collection<?> c)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.networks.containsAll( c );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEmpty()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.networks.isEmpty();
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterator<Grid> iterator()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.networks.iterator();
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean remove(Object o)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.copy();
|
|
|
|
return this.networks.remove( o );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean removeAll(Collection<?> c)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.copy();
|
|
|
|
return this.networks.removeAll( c );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean retainAll(Collection<?> c)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.copy();
|
|
|
|
return this.networks.retainAll( c );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void copy()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
List<Grid> old = this.networks;
|
|
|
|
this.networks = new LinkedList<Grid>();
|
|
|
|
this.networks.addAll( old );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int size()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.networks.size();
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object[] toArray()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.networks.toArray();
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public <T> T[] toArray(T[] a)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.networks.toArray( a );
|
2014-02-19 06:26:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|