Search code examples
javaswift-mt

how to Iterate over two list of different size?


I have two Lists of swift tags.

List<SwiftTagListBlock> source_tagListBlock = source_block4.getSubBlocks("16R", "16S");
List<SwiftTagListBlock> target_tagListBlock = target_block4.getSubBlocks("16R", "16S");

How to compare the values in list in the swift blocks.

for (int i = 0; i < source_tagListBlock.size(); i++) {
    SwiftTagListBlock blockList = source_tagListBlock.get(i);

    Iterator<Tag> tagIterator = blockList.tagIterator();

    while (tagIterator.hasNext()) {
        Tag tag = (Tag) tagIterator.next();
        //System.out.println(tag.getName() + "    " + tag.getValue());          
    }
}

The above two list are of different size. I want to compare the tag-name with the tag-values of another list.If there is any difference then write it to a file.


Solution

  • Got solution from this link. I will compare each of them tags by tags. If the tags are not found then write the differences.

    https://stackoverflow.com/a/37028146/5599600