Example usage for java.util AbstractSet AbstractSet

List of usage examples for java.util AbstractSet AbstractSet

Introduction

In this page you can find the example usage for java.util AbstractSet AbstractSet.

Prototype

protected AbstractSet() 

Source Link

Document

Sole constructor.

Usage

From source file:com.baobao.utils.cache.SequencedHashMap.java

/**
 *  Implements {@link Map#entrySet()}./*  w  w w .j  a  v a  2  s . co m*/
 */
public Set entrySet() {
    return new AbstractSet() {
        // helper
        private Entry findEntry(Object o) {
            if (o == null)
                return null;
            if (!(o instanceof Map.Entry))
                return null;

            Map.Entry e = (Map.Entry) o;
            Entry entry = (Entry) entries.get(e.getKey());
            if (entry != null && entry.equals(e))
                return entry;
            else
                return null;
        }

        // required impl
        public Iterator iterator() {
            return new OrderedIterator(ENTRY);
        }

        public boolean remove(Object o) {
            Entry e = findEntry(o);
            if (e == null)
                return false;

            return SequencedHashMap.this.removeImpl(e.getKey()) != null;
        }

        // more efficient impls than abstract collection
        public void clear() {
            SequencedHashMap.this.clear();
        }

        public int size() {
            return SequencedHashMap.this.size();
        }

        public boolean isEmpty() {
            return SequencedHashMap.this.isEmpty();
        }

        public boolean contains(Object o) {
            return findEntry(o) != null;
        }
    };
}

From source file:com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.java

/**
 * Returns a collection view of the mappings contained in this map.
 * Each element in the returned collection is a <tt>Map.Entry</tt>.  The
 * collection is backed by the map, so changes to the map are reflected in
 * the collection, and vice-versa.  The collection supports element
 * removal, which removes the corresponding mapping from the map, via the
 * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
 * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations.
 * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.
 *
 * @return a collection view of the mappings contained in this map.
 *//* www  .  j a v a  2s  .c o m*/
public Set entrySet() {
    Set es = entrySet;

    if (es != null) {
        return es;
    } else {
        return entrySet = new AbstractSet() {
            public Iterator iterator() {
                return new HashIterator();
            }

            public boolean contains(Object o) {
                if (!(o instanceof Map.Entry)) {
                    return false;
                }

                Map.Entry entry = (Map.Entry) o;
                Object key = entry.getKey();
                Object v = AbstractConcurrentReadCache.this.get(key);

                return (v != null) && v.equals(entry.getValue());
            }

            public boolean remove(Object o) {
                if (!(o instanceof Map.Entry)) {
                    return false;
                }

                return AbstractConcurrentReadCache.this.findAndRemoveEntry((Map.Entry) o);
            }

            public int size() {
                return AbstractConcurrentReadCache.this.size();
            }

            public void clear() {
                AbstractConcurrentReadCache.this.clear();
            }
        };
    }
}

From source file:SoftValuedHashMap.java

public Set<Map.Entry<K, V>> entrySet() {
    if (this.entrySet == null) {
        this.entrySet = new AbstractSet<Map.Entry<K, V>>() {
            public Iterator iterator() {
                return createHashIterator(WeakIdentityMap.ENTRIES);
            }//from w ww . j a  va2  s.c  o  m

            public boolean contains(Object o) {
                if (!(o instanceof Map.Entry)) {
                    return false;
                }
                Map.Entry entry = (Map.Entry) o;
                Object key = entry.getKey();

                Entry[] tab = ReferencedValueHashMap.this.table;
                int hash = key == null ? 0 : key.hashCode();
                int index = (hash & 0x7fffffff) % tab.length;

                for (Entry e = tab[index], prev = null; e != null; e = e.next) {
                    Object entryValue = e.get();

                    if (entryValue == null) {
                        // Clean up after a cleared Reference.
                        ReferencedValueHashMap.this.modCount++;
                        if (prev != null) {
                            prev.next = e.next;
                        } else {
                            tab[index] = e.next;
                        }
                        ReferencedValueHashMap.this.count--;
                    } else if (e.hash == hash && e.equals(entry)) {
                        return true;
                    } else {
                        prev = e;
                    }
                }

                return false;
            }

            public boolean remove(Object o) {
                if (!(o instanceof Map.Entry)) {
                    return false;
                }
                Map.Entry entry = (Map.Entry) o;
                Object key = entry.getKey();
                Entry[] tab = ReferencedValueHashMap.this.table;
                int hash = key == null ? 0 : key.hashCode();
                int index = (hash & 0x7fffffff) % tab.length;

                for (Entry e = tab[index], prev = null; e != null; e = e.next) {
                    Object entryValue = e.get();

                    if (entryValue == null) {
                        // Clean up after a cleared Reference.
                        ReferencedValueHashMap.this.modCount++;
                        if (prev != null) {
                            prev.next = e.next;
                        } else {
                            tab[index] = e.next;
                        }
                        ReferencedValueHashMap.this.count--;
                    } else if (e.hash == hash && e.equals(entry)) {
                        ReferencedValueHashMap.this.modCount++;
                        if (prev != null) {
                            prev.next = e.next;
                        } else {
                            tab[index] = e.next;
                        }
                        ReferencedValueHashMap.this.count--;

                        e.setValue(null);
                        return true;
                    } else {
                        prev = e;
                    }
                }
                return false;
            }

            public int size() {
                return ReferencedValueHashMap.this.count;
            }

            public void clear() {
                ReferencedValueHashMap.this.clear();
            }

            public String toString() {
                return WeakIdentityMap.toString(this);
            }
        };
    }

    return this.entrySet;
}

From source file:uniol.apt.adt.ts.TransitionSystem.java

/**
 * Gets a view of the alphabet of the TransitionSystem as an unmodifiableSortedSet.
 * @return the alphabet of this TransitionSystem.
 *///ww w.j a  va2  s . c  o m
public Set<String> getAlphabet() {
    final Set<Event> events = this.alphabetSet;
    return new AbstractSet<String>() {
        @Override
        public int size() {
            return events.size();
        }

        @Override
        public Iterator<String> iterator() {
            return new Iterator<String>() {
                private Iterator<Event> it = events.iterator();

                @Override
                public boolean hasNext() {
                    return it.hasNext();
                }

                @Override
                public String next() {
                    return it.next().getLabel();
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}

From source file:com.taobao.android.PatchFieldTool.java

public static void addField(String inFile, String outFile, DexBackedClassDef dexBackedClassDef,
        ImmutableField immutableField) throws IOException {

    DexFile dexFile = readDexFile(inFile);
    for (ClassDef classDef : dexFile.getClasses()) {
        if (dexBackedClassDef != null && dexBackedClassDef.getType().equals(classDef.getType())) {
            dexFile = addField(dexFile, classDef.getType(), immutableField);
        } else if (dexBackedClassDef == null) {
            dexFile = addField(dexFile, classDef.getType(), immutableField);

        }/*from   ww w. java2s.co m*/
    }
    reDexFile(dexFile);

    DexFileFactory.writeDexFile(outFile, new DexFile() {
        @Nonnull
        @Override
        public Set<? extends ClassDef> getClasses() {
            return new AbstractSet<ClassDef>() {
                @Nonnull
                @Override
                public Iterator<ClassDef> iterator() {
                    return classes.iterator();
                }

                @Override
                public int size() {
                    return classes.size();
                }
            };
        }
    });
}

From source file:com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache.java

/**
 * Returns a set view of the keys contained in this map.
 * The set is backed by the map, so changes to the map are reflected in the set, and
 * vice-versa.  The set supports element removal, which removes the
 * corresponding mapping from this map, via the <tt>Iterator.remove</tt>,
 * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and
 * <tt>clear</tt> operations.  It does not support the <tt>add</tt> or
 * <tt>addAll</tt> operations.
 *
 * @return a set view of the keys contained in this map.
 *//*from  www. jav a 2s  .c  o  m*/
public Set keySet() {
    Set ks = keySet;

    if (ks != null) {
        return ks;
    } else {
        return keySet = new AbstractSet() {
            public Iterator iterator() {
                return new KeyIterator();
            }

            public int size() {
                return AbstractConcurrentReadCache.this.size();
            }

            public boolean contains(Object o) {
                return AbstractConcurrentReadCache.this.containsKey(o);
            }

            public boolean remove(Object o) {
                return AbstractConcurrentReadCache.this.remove(o) != null;
            }

            public void clear() {
                AbstractConcurrentReadCache.this.clear();
            }
        };
    }
}

From source file:uniol.apt.adt.ts.TransitionSystem.java

@Override
public Set<Arc> getEdges() {
    return new AbstractSet<Arc>() {
        @Override/*from   w w  w. j av a  2s  .  co m*/
        public int size() {
            return TransitionSystem.this.numArcs;
        }

        @Override
        public Iterator<Arc> iterator() {
            return new Iterator<Arc>() {
                private Iterator<State> stateIter = TransitionSystem.this.states.values().iterator();
                private Iterator<Arc> arcIter = emptyIterator();

                @Override
                public boolean hasNext() {
                    while (!arcIter.hasNext() && stateIter.hasNext())
                        arcIter = stateIter.next().postsetEdges.values().iterator();
                    return arcIter.hasNext();
                }

                @Override
                public Arc next() {
                    // Update arcIter, if needed
                    hasNext();
                    return arcIter.next();
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}

From source file:com.taobao.android.FastPatchTool.java

public void doPatch() throws IOException, PatchException, RecognitionException {
    MappingReader mappingReader = null;//  w  w w.  j  av a 2s. co m
    MappingProcessor mappingProcessor = null;

    if (outDir == null || !outDir.exists()) {
        return;
    }
    outPatchFile = new File(outDir, "apatch-unsigned.apatch");

    if (mappingFile != null && mappingFile.exists()) {
        mappingReader = new MappingReader(mappingFile);
        mappingProcessor = new MappingProcessorImpl(superClassMap);
        mappingReader.pump(mappingProcessor);
        mappingProcessor.updateMethod();
        mappingProcessor.updateFieldType();
    }

    for (FastPatchObject fastPatchObject : patchObjects) {
        Set<ClassDef> classes = new HashSet<ClassDef>();
        Map<ClassDef, List<Method>> patchClassDefs = new HashMap<ClassDef, List<Method>>();
        Set<ClassDef> addedClasses = new HashSet<ClassDef>();
        Map<ClassDef, List<Method>> newClassDef = new HashMap<ClassDef, List<Method>>();

        ArrayList<Method> methods = new ArrayList<Method>();

        for (File dexFile : fastPatchObject.DexFiles) {
            DexFile dFile = DexFileFactory.loadDexFile(dexFile.getAbsolutePath(), 19, true);
            classes.addAll(dFile.getClasses());
        }
        final Set<ClassDef> newClasses = new HashSet<ClassDef>();
        for (ClassDef classDef : classes) {
            String type = classDef.getType();
            if (fastPatchObject.addedClass.contains(SmaliUtils.getDalvikClassName(type))) {
                System.out.println("patch added class:" + type);
                addedClasses.add(classDef);
                continue;
            }
            for (Map.Entry<String, List<String>> entry : fastPatchObject.modifyClasses.entrySet()) {
                if (entry.getKey().equals(SmaliUtils.getDalvikClassName(type))) {
                    ArrayList<Method> newMethods = new ArrayList<Method>();
                    for (Method method : classDef.getMethods()) {
                        System.err.println(getMethodFullName(method));
                        if (entry.getValue().contains(getMethodFullName(method))) {
                            newMethods.add(method);
                        }

                    }
                    patchClassDefs.put(classDef, newMethods);
                    break;
                }
            }
        }
        if (patchClassDefs.size() == 0 && addedClasses.size() == 0) {
            continue;
        }

        if (mappingFile != null && mappingFile.exists()) {
            //prepareclass
            for (String className : fastPatchObject.prepareClasses) {
                ApkPatch.prepareClasses.add(mappingProcessor.getNewClassName(className).className);
            }
            //replaceanatation
            MethodReplaceAnnotation.ANNOTATION = DefineUtils
                    .getDefineClassName(mappingProcessor.getNewClassName(DefineUtils.getDalvikClassName(
                            "Lcom/alipay/euler/andfix/annotation/MethodReplace;")).className, false);
            //dex?
            InsTructionsReIClassDef insTructionsReDef = new InsTructionsReIClassDef(
                    new MappingClassProcessor(mappingProcessor));
            for (ClassDef c : classes) {
                if (patchClassDefs.containsKey(c)) {
                    for (Method method : c.getMethods()) {
                        if (patchClassDefs.get(c).contains(method)) {
                            methods.add(insTructionsReDef.reMethod(method));
                        }
                    }
                    newClassDef.put(insTructionsReDef.reClassDef(c), methods);
                } else if (addedClasses.contains(c)) {
                    newClassDef.put(insTructionsReDef.reClassDef(c), new ArrayList<Method>());
                }
                if (c.getType().contains("/R$")) {
                    continue;
                }
                newClasses.add(insTructionsReDef.reClassDef(c));
            }

        } else {
            ApkPatch.prepareClasses.addAll(fastPatchObject.prepareClasses);
        }

        File patchDexFile = new File(outDir, "patch.dex");
        for (ClassDef classDef : newClassDef.keySet()) {
            System.out.println("modify class:" + classDef.getType());
        }
        if (newClassDef.size() > 0) {
            DexFileFactory.writeDexFile(patchDexFile.getAbsolutePath(),
                    new ImmutableDexFile(newClassDef.keySet()));
        } else if (patchClassDefs.size() > 0) {
            DexFileFactory.writeDexFile(patchDexFile.getAbsolutePath(),
                    new ImmutableDexFile(patchClassDefs.keySet()));
        }

        File tempDexFile = new File(outDir, "temp.dex");
        if (newClasses.size() > 0) {
            DexFileFactory.writeDexFile(tempDexFile.getAbsolutePath(), new DexFile() {
                @Nonnull
                @Override
                public Set<? extends ClassDef> getClasses() {
                    return new AbstractSet<ClassDef>() {
                        @Nonnull
                        @Override
                        public Iterator<ClassDef> iterator() {
                            return newClasses.iterator();
                        }

                        @Override
                        public int size() {
                            return newClasses.size();
                        }
                    };
                }
            });
        } else if (classes.size() > 0) {
            DexFileFactory.writeDexFile(tempDexFile.getAbsolutePath(), new ImmutableDexFile(classes));

        }

        SmaliDiffUtils.scanClasses(new File(outDir, "smali2"), Lists.newArrayList(tempDexFile));

        DexFile patchDex = DexFileFactory.loadDexFile(patchDexFile.getAbsolutePath(), 19, true);
        DexFile tempDex = DexFileFactory.loadDexFile(tempDexFile.getAbsolutePath(), 19, true);
        Set<? extends ClassDef> patchClasses = patchDex.getClasses();
        DexDiffInfo dexDiffInfo = new DexDiffInfo();
        for (ClassDef patchClassDef : patchClasses) {
            String type = patchClassDef.getType();
            if (fastPatchObject.addedClass.contains(SmaliUtils.getDalvikClassName(type))) {
                dexDiffInfo.getAddedClasses().add((DexBackedClassDef) patchClassDef);
                dexDiffInfo.addManifestAddClass(type);
                continue;
            }

            for (Method method : patchClassDef.getMethods()) {
                List<? extends CharSequence> parameters = method.getParameterTypes();
                if (methods.size() > 0) {
                    for (Method modifyMethod : methods) {
                        List<? extends CharSequence> modifyParameters = modifyMethod.getParameterTypes();
                        if (parameters.size() != modifyParameters.size()
                                || !isEqualObj(parameters, modifyParameters)) {
                            continue;
                        }

                        if (modifyMethod.getName().equals(method.getName()))
                            dexDiffInfo.addModifiedMethods((DexBackedMethod) method);
                    }
                } else if (patchClassDefs.size() > 0) {
                    for (ClassDef classDef : patchClassDefs.keySet()) {
                        if (classDef.getType().equals(patchClassDef.getType())) {
                            List<Method> methodList = patchClassDefs.get(classDef);
                            for (Method method1 : methodList) {
                                if (method1.getName().equals(method.getName())) {
                                    dexDiffInfo.addModifiedMethods((DexBackedMethod) method);
                                }
                            }
                        }
                    }

                }
            }
        }
        FastBuild fastBuild = new FastBuild(fastPatchObject.bundleName, new File(outDir, bundleName));
        fastBuild.setClasses(tempDex.getClasses());
        fastBuild.setDiffInfo(dexDiffInfo);
        new AndFixFilterImpl(dexDiffInfo).filterDex();
        dexDiffInfo.update();
        APatchTool.isApatch = true;
        File adiffFile = new File(outDir, "apatch-diff.txt");
        File adiffJsonFile = new File(outDir, "apatch-diff.json");
        dexDiffInfo.writeToFile(fastPatchObject.bundleName, adiffFile, adiffJsonFile);
        try {
            File patchJarFile = fastBuild.dopatch();
            patchJarFiles.add(patchJarFile);
        } catch (CertificateException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyStoreException e) {
            e.printStackTrace();
        } catch (UnrecoverableEntryException e) {
            e.printStackTrace();
        }
    }

    File[] aPatchFiles = new File[patchJarFiles.size()];
    aPatchFiles = patchJarFiles.toArray(aPatchFiles);
    File mergePatchFile = null;
    if (null != aPatchFiles && aPatchFiles.length > 1) {
        MergePatch mergePatch = new MergePatch(aPatchFiles, "com_taobao_android", outDir);
        mergePatchFile = mergePatch.doMerge();
    } else if (null != aPatchFiles && aPatchFiles.length == 1) {
        mergePatchFile = aPatchFiles[0];
    }
    if (null != mergePatchFile && mergePatchFile.exists()) {
        FileUtils.moveFile(mergePatchFile, outPatchFile);
    }

}

From source file:com.taobao.android.tools.FastPatchTool.java

public void doPatch() throws IOException, PatchException, RecognitionException {
    MappingReader mappingReader = null;//from w ww  .  j av a  2s  .c o m
    MappingProcessor mappingProcessor = null;

    if (outDir == null || !outDir.exists()) {
        return;
    }
    outPatchFile = new File(outDir, "apatch-unsigned.apatch");

    if (mappingFile != null && mappingFile.exists()) {
        mappingReader = new MappingReader(mappingFile);
        mappingProcessor = new MappingProcessorImpl(superClassMap);
        mappingReader.pump(mappingProcessor);
        mappingProcessor.updateMethod();
        mappingProcessor.updateFieldType();
    }

    for (FastPatchObject fastPatchObject : patchObjects) {
        Set<ClassDef> classes = new HashSet<ClassDef>();
        Map<ClassDef, List<Method>> patchClassDefs = new HashMap<ClassDef, List<Method>>();
        Set<ClassDef> addedClasses = new HashSet<ClassDef>();
        Map<ClassDef, List<Method>> newClassDef = new HashMap<ClassDef, List<Method>>();

        ArrayList<Method> methods = new ArrayList<Method>();

        for (File dexFile : fastPatchObject.DexFiles) {
            DexFile dFile = DexFileFactory.loadDexFile(dexFile.getAbsolutePath(), Opcodes.getDefault());
            classes.addAll(dFile.getClasses());
        }
        final Set<ClassDef> newClasses = new HashSet<ClassDef>();
        for (ClassDef classDef : classes) {
            String type = classDef.getType();
            if (fastPatchObject.addedClass.contains(SmaliUtils.getDalvikClassName(type))) {
                System.out.println("patch added class:" + type);
                addedClasses.add(classDef);
                continue;
            }
            for (Map.Entry<String, List<String>> entry : fastPatchObject.modifyClasses.entrySet()) {
                if (entry.getKey().equals(SmaliUtils.getDalvikClassName(type))) {
                    ArrayList<Method> newMethods = new ArrayList<Method>();
                    for (Method method : classDef.getMethods()) {
                        System.err.println(getMethodFullName(method));
                        if (entry.getValue().contains(getMethodFullName(method))) {
                            newMethods.add(method);
                        }

                    }
                    patchClassDefs.put(classDef, newMethods);
                    break;
                }
            }
        }
        if (patchClassDefs.size() == 0 && addedClasses.size() == 0) {
            continue;
        }

        if (mappingFile != null && mappingFile.exists()) {
            //prepareclass
            for (String className : fastPatchObject.prepareClasses) {
                ApkPatch.prepareClasses.add(mappingProcessor.getNewClassName(className).className);
            }
            //replaceanatation
            MethodReplaceAnnotation.ANNOTATION = DefineUtils
                    .getDefineClassName(mappingProcessor.getNewClassName(DefineUtils.getDalvikClassName(
                            "Lcom/alipay/euler/andfix/annotation/MethodReplace;")).className, false);
            //dex?
            InsTructionsReIClassDef insTructionsReDef = new InsTructionsReIClassDef(
                    new MappingClassProcessor(mappingProcessor));
            for (ClassDef c : classes) {
                if (patchClassDefs.containsKey(c)) {
                    for (Method method : c.getMethods()) {
                        if (patchClassDefs.get(c).contains(method)) {
                            methods.add(insTructionsReDef.reMethod(method));
                        }
                    }
                    newClassDef.put(insTructionsReDef.reClassDef(c), methods);
                } else if (addedClasses.contains(c)) {
                    newClassDef.put(insTructionsReDef.reClassDef(c), new ArrayList<Method>());
                }
                if (c.getType().contains("/R$")) {
                    continue;
                }
                newClasses.add(insTructionsReDef.reClassDef(c));
            }

        } else {
            ApkPatch.prepareClasses.addAll(fastPatchObject.prepareClasses);
        }

        File patchDexFile = new File(outDir, "patch.dex");
        for (ClassDef classDef : newClassDef.keySet()) {
            System.out.println("modify class:" + classDef.getType());
        }
        if (newClassDef.size() > 0) {
            DexFileFactory.writeDexFile(patchDexFile.getAbsolutePath(),
                    new ImmutableDexFile(Opcodes.getDefault(), newClassDef.keySet()));
        } else if (patchClassDefs.size() > 0) {
            DexFileFactory.writeDexFile(patchDexFile.getAbsolutePath(),
                    new ImmutableDexFile(Opcodes.getDefault(), patchClassDefs.keySet()));
        }

        File tempDexFile = new File(outDir, "temp.dex");
        if (newClasses.size() > 0) {
            DexFileFactory.writeDexFile(tempDexFile.getAbsolutePath(), new DexFile() {
                @Nonnull
                @Override
                public Set<? extends ClassDef> getClasses() {
                    return new AbstractSet<ClassDef>() {
                        @Nonnull
                        @Override
                        public Iterator<ClassDef> iterator() {
                            return newClasses.iterator();
                        }

                        @Override
                        public int size() {
                            return newClasses.size();
                        }
                    };
                }

                @Nonnull
                @Override
                public Opcodes getOpcodes() {
                    return Opcodes.getDefault();
                }
            });
        } else if (classes.size() > 0) {
            DexFileFactory.writeDexFile(tempDexFile.getAbsolutePath(),
                    new ImmutableDexFile(Opcodes.getDefault(), classes));

        }

        SmaliDiffUtils.scanClasses(new File(outDir, "smali2"), Lists.newArrayList(tempDexFile));

        DexFile patchDex = DexFileFactory.loadDexFile(patchDexFile.getAbsolutePath(), Opcodes.getDefault());
        DexFile tempDex = DexFileFactory.loadDexFile(tempDexFile.getAbsolutePath(), Opcodes.getDefault());
        Set<? extends ClassDef> patchClasses = patchDex.getClasses();
        DexDiffInfo dexDiffInfo = new DexDiffInfo();
        for (ClassDef patchClassDef : patchClasses) {
            String type = patchClassDef.getType();
            if (fastPatchObject.addedClass.contains(SmaliUtils.getDalvikClassName(type))) {
                dexDiffInfo.getAddedClasses().add((DexBackedClassDef) patchClassDef);
                dexDiffInfo.addManifestAddClass(type);
                continue;
            }

            for (Method method : patchClassDef.getMethods()) {
                List<? extends CharSequence> parameters = method.getParameterTypes();
                if (methods.size() > 0) {
                    for (Method modifyMethod : methods) {
                        List<? extends CharSequence> modifyParameters = modifyMethod.getParameterTypes();
                        if (parameters.size() != modifyParameters.size()
                                || !isEqualObj(parameters, modifyParameters)) {
                            continue;
                        }

                        if (modifyMethod.getName().equals(method.getName()))
                            dexDiffInfo.addModifiedMethods((DexBackedMethod) method);
                    }
                } else if (patchClassDefs.size() > 0) {
                    for (ClassDef classDef : patchClassDefs.keySet()) {
                        if (classDef.getType().equals(patchClassDef.getType())) {
                            List<Method> methodList = patchClassDefs.get(classDef);
                            for (Method method1 : methodList) {
                                if (method1.getName().equals(method.getName())) {
                                    dexDiffInfo.addModifiedMethods((DexBackedMethod) method);
                                }
                            }
                        }
                    }

                }
            }
        }
        FastBuild fastBuild = new FastBuild(fastPatchObject.bundleName, new File(outDir, bundleName));
        fastBuild.setClasses(tempDex.getClasses());
        fastBuild.setDiffInfo(dexDiffInfo);
        new AndFixFilterImpl(dexDiffInfo).filterDex();
        dexDiffInfo.update();
        File adiffFile = new File(outDir, "apatch-diff.txt");
        File adiffJsonFile = new File(outDir, "apatch-diff.json");
        dexDiffInfo.writeToFile(fastPatchObject.bundleName, adiffFile, adiffJsonFile);
        try {
            File patchJarFile = fastBuild.dopatch();
            patchJarFiles.add(patchJarFile);
        } catch (CertificateException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyStoreException e) {
            e.printStackTrace();
        } catch (UnrecoverableEntryException e) {
            e.printStackTrace();
        }
    }

    File[] aPatchFiles = new File[patchJarFiles.size()];
    aPatchFiles = patchJarFiles.toArray(aPatchFiles);
    File mergePatchFile = null;
    if (null != aPatchFiles && aPatchFiles.length > 1) {
        MergePatch mergePatch = new MergePatch(aPatchFiles, "com_taobao_android", outDir);
        mergePatchFile = mergePatch.doMerge();
    } else if (null != aPatchFiles && aPatchFiles.length == 1) {
        mergePatchFile = aPatchFiles[0];
    }
    if (null != mergePatchFile && mergePatchFile.exists()) {
        FileUtils.moveFile(mergePatchFile, outPatchFile);
    }

}

From source file:uniol.apt.adt.pn.PetriNet.java

@Override
public Set<Flow> getEdges() {
    return new AbstractSet<Flow>() {
        @Override//  w w w .j  a v a2s.  com
        public int size() {
            return PetriNet.this.numFlows;
        }

        @Override
        public Iterator<Flow> iterator() {
            return new Iterator<Flow>() {
                private Iterator<Map<EdgeKey, Flow>> postsetIter = PetriNet.this.postsetEdges.values()
                        .iterator();
                private Iterator<Flow> flowIter = emptyIterator();

                @Override
                public boolean hasNext() {
                    while (!flowIter.hasNext() && postsetIter.hasNext())
                        flowIter = postsetIter.next().values().iterator();
                    return flowIter.hasNext();
                }

                @Override
                public Flow next() {
                    // Update flowIter, if needed
                    hasNext();
                    return flowIter.next();
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}