How to compare and remove objects from a Set<E> based on condition
<p>I have a Set named scripts. The class E has elements like id,squence and many more . I want to compare two rows of object E in scripts and remove only if id and sequence are same . how do I do it .I have a code that removes all the rows . Can anyone correct this code to remove only the ones that has id and sequence same .</p>

<pre><code>        LinkedList&lt;EditorScriptRow&gt; lList = new LinkedList&lt;EditorScriptRow&gt;       (_scriptRows);

     for (ListIterator&lt;EditorScriptRow&gt; i = lList.listIterator(); i.hasNext();) {
           EditorScriptRow row = i.next();
         int k =0;
        for (ListIterator&lt;EditorScriptRow&gt; j = lList.listIterator(k+1) j.hasNext();) {

           EditorScriptRow row1 = j.next();

            if ((row.getTemplateRow().getId() != null) &amp;&amp; 
               (row.getSequence() != null) &amp;&amp; 
                (row.getEdit().getName() != null) ) {
                if ((row.getSequence().equals(row1.getSequence())) &amp;&amp;
                    (row.getTemplateRow().getId().equals(row1.getTemplateRow  ().getId      ())) &amp;&amp; 
                    (row.getEdit().getName().equals(row1.getEdit().getName()))) {
                        _scriptRows.remove(row);
                }
        }
    }
k++;
}
</code></pre>
