void sendViewChangeNotifications(View view, List<Address> new_mbrs, List<Address> old_mbrs) { if((notifs.isEmpty()) || (old_mbrs == null) || (new_mbrs == null)) return; // 1. Compute set of members that joined: all that are in new_mbrs, but not in old_mbrs List<Address> joined=new_mbrs.stream().filter(mbr -> !old_mbrs.contains(mbr)).collect(Collectors.toList()); // 2. Compute set of members that left: all that were in old_mbrs, but not in new_mbrs List<Address> left=old_mbrs.stream().filter(mbr -> !new_mbrs.contains(mbr)).collect(Collectors.toList()); notifs.forEach( notif -> notif.viewChange(view, joined, left)); }
void sendViewChangeNotifications(View view, List<Address> new_mbrs, List<Address> old_mbrs) { if((notifs.isEmpty()) || (old_mbrs == null) || (new_mbrs == null)) return; // 1. Compute set of members that joined: all that are in new_mbrs, but not in old_mbrs List<Address> joined=new_mbrs.stream().filter(mbr -> !old_mbrs.contains(mbr)).collect(Collectors.toList()); // 2. Compute set of members that left: all that were in old_mbrs, but not in new_mbrs List<Address> left=old_mbrs.stream().filter(mbr -> !new_mbrs.contains(mbr)).collect(Collectors.toList()); notifs.forEach( notif -> notif.viewChange(view, joined, left)); }
void sendViewChangeNotifications(View view, Vector<Address> new_mbrs, Vector<Address> old_mbrs) { Vector<Address> joined, left; Notification n; if((notifs.isEmpty()) || (old_mbrs == null) || (new_mbrs == null) || (old_mbrs.isEmpty()) || (new_mbrs.isEmpty())) return; // 1. Compute set of members that joined: all that are in new_mbrs, but not in old_mbrs joined=new Vector<Address>(); for(Address mbr: new_mbrs) { if(!old_mbrs.contains(mbr)) joined.addElement(mbr); } // 2. Compute set of members that left: all that were in old_mbrs, but not in new_mbrs left=new Vector<Address>(); for(Address mbr: old_mbrs) { if(!new_mbrs.contains(mbr)) { left.addElement(mbr); } } for(int i=0; i < notifs.size(); i++) { n=notifs.elementAt(i); n.viewChange(view, joined, left); } }