public static void main(String[] args) throws IOException
    {
        long start = System.currentTimeMillis();
        BufferedReader tagFile = new BufferedReader(new FileReader(args[0]));
        BufferedReader alternateFile = new BufferedReader(new FileReader(args[1]));

        HashMap<String, LinkedList<Tag>> tags = getTags(tagFile);
        tagFile.close();

        HashMap<String, LinkedList<Tag>> alternates = getTags(alternateFile);
        alternateFile.close();

        Set<Tag> overlaps = new HashSet<Tag>();

        for (String id : tags.keySet())
        {
            LinkedList<Tag> alternateTags = alternates.get(id);
            if (alternateTags != null)
            {
                for (Tag tag : tags.get(id))
                {
                    for (Tag alternate : alternateTags)
                    {
                        if (tag.overlaps(alternate))
                            overlaps.add(tag);
                    }
                }
            }
        }
        System.out.println("Overlaps: " + overlaps.size());
        System.out.println("Took " + (System.currentTimeMillis() - start) + " ms");
    }
public static void main ( String [ ] args ) throws IOException { long start = System . currentTimeMillis ( ) ; BufferedReader tagFile = new BufferedReader ( new FileReader ( args [ 0 ] ) ) ; BufferedReader alternateFile = new BufferedReader ( new FileReader ( args [ 1 ] ) ) ; HashMap < String , LinkedList < Tag > > tags = getTags ( tagFile ) ; tagFile . close ( ) ; HashMap < String , LinkedList < Tag > > alternates = getTags ( alternateFile ) ; alternateFile . close ( ) ; Set < Tag > overlaps = new HashSet < Tag > ( ) ; for ( String id : tags . keySet ( ) ) { LinkedList < Tag > alternateTags = alternates . get ( id ) ; if ( alternateTags != null ) { for ( Tag tag : tags . get ( id ) ) { for ( Tag alternate : alternateTags ) { if ( tag . overlaps ( alternate ) ) overlaps . add ( tag ) ; } } } } System . out . println ( "Overlaps: " + overlaps . size ( ) ) ; System . out . println ( "Took " + ( System . currentTimeMillis ( ) - start ) + " ms" ) ; }
@param args