1 52 53 package com.go.trove.classfile; 54 55 import java.util.*; 56 57 65 class LocationRangeSet { 66 69 public static SortedSet reduce(SortedSet locations) { 70 SortedSet newSet = new TreeSet(); 71 Iterator it = locations.iterator(); 72 73 while (it.hasNext()) { 74 LocationRange next = (LocationRange)it.next(); 75 76 if (newSet.size() == 0) { 77 newSet.add(next); 78 continue; 79 } 80 81 if (next.getStartLocation().compareTo 82 (next.getEndLocation()) >= 0) { 83 continue; 84 } 85 86 89 LocationRange last = (LocationRange)newSet.last(); 90 91 if (next.getStartLocation().compareTo 92 (last.getEndLocation()) <= 0) { 93 94 if (last.getEndLocation().compareTo 95 (next.getEndLocation()) <= 0) { 96 97 newSet.remove(last); 98 newSet.add(new LocationRangeImpl(last, next)); 99 } 100 continue; 101 } 102 103 newSet.add(next); 104 } 105 106 return newSet; 107 } 108 } 109 | Popular Tags |