Changeset 3147 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2010-03-19T22:21:52+01:00 (15 years ago)
Author:
jttt
Message:

Use virtual collections for Dataset.all... methods

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r3116 r3147  
    163163
    164164    /**
    165      * @return A collection containing all primitives of the dataset. The data is ordered after:
    166      * first come nodes, then ways, then relations. Ordering in between the categories is not
    167      * guaranteed.
    168      */
    169     public List<OsmPrimitive> allPrimitives() {
    170         List<OsmPrimitive> o = new LinkedList<OsmPrimitive>();
    171         o.addAll(nodes);
    172         o.addAll(ways);
    173         o.addAll(relations);
    174         return o;
     165     * @return A collection containing all primitives of the dataset. Data are not ordered
     166     */
     167    public Collection<OsmPrimitive> allPrimitives() {
     168        return Collections.unmodifiableCollection(allPrimitives);
    175169    }
    176170
     
    179173     */
    180174    public Collection<OsmPrimitive> allNonDeletedPrimitives() {
    181         Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>();
    182         for (OsmPrimitive osm : allPrimitives())
    183             if (osm.isVisible() && !osm.isDeleted()) {
    184                 o.add(osm);
    185             }
    186         return o;
     175        return new DatasetCollection.AllNonDeleted(allPrimitives);
    187176    }
    188177
    189178    public Collection<OsmPrimitive> allNonDeletedCompletePrimitives() {
    190         Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>();
    191         for (OsmPrimitive osm : allPrimitives())
    192             if (osm.isVisible() && !osm.isDeleted() && !osm.isIncomplete()) {
    193                 o.add(osm);
    194             }
    195         return o;
     179        return new DatasetCollection.AllNonDeletedComplete(allPrimitives);
    196180    }
    197181
    198182    public Collection<OsmPrimitive> allNonDeletedPhysicalPrimitives() {
    199         Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>();
    200         for (OsmPrimitive osm : allPrimitives())
    201             if (osm.isVisible() && !osm.isDeleted() && !osm.isIncomplete() && !(osm instanceof Relation)) {
    202                 o.add(osm);
    203             }
    204         return o;
     183        return new DatasetCollection.AllNonDeletedPhysical(allPrimitives);
    205184    }
    206185
     
    209188     */
    210189    public Collection<OsmPrimitive> allModifiedPrimitives() {
    211         Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>();
    212         for (OsmPrimitive osm : allPrimitives()) {
    213             if (osm.isVisible() && osm.isModified()) {
    214                 o.add(osm);
    215             }
    216         }
    217         return o;
     190        return new DatasetCollection.AllModified(allPrimitives);
    218191    }
    219192
Note: See TracChangeset for help on using the changeset viewer.