var myArray = [
{id: 1, name: 'Вася', age: 21, city: 'Москва'},
{id: 2, name: 'Коля', age: 22, city: 'Новгород'},
{id: 3, name: 'Петя', age: 23, city: 'Челябинск'},
{id: 4, name: 'Саша', age: 24, city: 'Омск'},
{id: 5, name: 'Ваня', age: 99, city: 'Омск'}
];
function filterByCity(arr, city) {
return arr.filter(function(item, i, arr) {
return (item.city == city);
});
};
var omsk = filterByCity(myArray, 'Омск');
console.log(omsk);
public class ReplaceFromMapTest {
public static void main(String[] args) {
if(deleteNamesake(getNames())) {
System.out.println("люди с одинаковыми именами были удалены из \"списка\".");
}
}
public static Map<String, String> getNames() {
Map<String, String> names = new HashMap<String, String>();
names.put("Иванов", "Иван");
names.put("Пупкин", "Вася");
names.put("Коваленко", "Петя");
names.put("Лубнов", "Иван");
return names;
}
public static boolean deleteNamesake(Map<String, String> names) {
boolean result = false;
Collection<String> allFirstNames = names.values();
Set<String> delNames = new HashSet<String>();
for(Map.Entry<String, String> p : names.entrySet()) {
if(Collections.frequency(allFirstNames, p.getValue()) > 1) {
delNames.add(p.getKey());
}
}
if(delNames.size() > 0) {
for(String n : delNames) {
names.remove(n);
result = true;
}
}
return result;
}
}
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:data="http://russianpost.org/operationhistory/data" xmlns:data1="http://www.russianpost.org/RTM/DataExchangeESPP/Data">
<soapenv:Header>
<data:AuthorizationHeader soapenv:mustUnderstand="1">
<data:login>?</data:login>
<data:password>?</data:password>
</data:AuthorizationHeader>
</soapenv:Header>
<soapenv:Body>
<data1:PostalOrderEventsForMailInput Barcode="?" Language="RUS"/>
</soapenv:Body>
</soapenv:Envelope>