Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1D689200AF5 for ; Thu, 2 Jun 2016 20:56:16 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1BF69160A52; Thu, 2 Jun 2016 18:56:16 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3C3A2160A3E for ; Thu, 2 Jun 2016 20:56:15 +0200 (CEST) Received: (qmail 71014 invoked by uid 500); 2 Jun 2016 18:56:14 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 71004 invoked by uid 99); 2 Jun 2016 18:56:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 18:56:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E58BDC06CD for ; Thu, 2 Jun 2016 18:56:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id wLubR_QeFpSj for ; Thu, 2 Jun 2016 18:56:11 +0000 (UTC) Received: from mail-it0-f54.google.com (mail-it0-f54.google.com [209.85.214.54]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id A9F6E5F24D for ; Thu, 2 Jun 2016 18:56:10 +0000 (UTC) Received: by mail-it0-f54.google.com with SMTP id e62so134573243ita.1 for ; Thu, 02 Jun 2016 11:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=UF9//UqIiyu/z2Se2YkHh+g7lx1fYnHr+iHpbgzKq5c=; b=NGeN6IdhAlEdJ42bBYIIQefNOIpnvn7+Zuycp2iFSHsSet0ePVaLdG9sqj+s2qKxXs etCbHw2NqS3SG/BsqHLosRWfIDS2Bm6qNHveGPDFwD7sEs+YTiXTJzqmkI8oc+BswVZS o0XsdNngIdTAYoCqd41230cjcLK90AwocYPIyVNC89jQXnsHkJoJYcgE41nkgtcdBJuM 2bhle1kNFCz/dZxs1GOqEiEudPgdGu3oYgP/juNNZOMsiEsXF+VcMB1IfRFtG6L61twv 3FB5lUfwFKFnhogmgY4YoxGmb0tkmAI+g5xAsB9bDBNUy28+nYJax+y9tZySP5sP/U4e qzbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=UF9//UqIiyu/z2Se2YkHh+g7lx1fYnHr+iHpbgzKq5c=; b=lHGQIuOgUmZoLrzMdO3fP650gbWxiKuf3gIQCMNsHBRnUVAXGzMcBr10s5Llfcq2Ns 4rhbLylXE+qZjfL0us/ToIqt0njg0FGdMAi7Fm/YNFmIYWNREfyPBMyQE1PMrxGGm5nP IKn0ny4JdCgWH98yBDGmP7dVJ1sgvgLvbgaWIHSb1t/4oSIFDu6xwU3ZPz2AU8a2Zx1y zFLARNUhDJRUmteVdyBBNJ+XmpPjCYsuWEn2DUgkorNClcXFJN+/sDB5VAEd8Xh+54y9 v4ly6ByKJxa8kLlz7YvHzxfzf3bVtaDIYBFRdWyJax/83pRzRpBAGLX4iCUyNiJmXhsP Jrcg== X-Gm-Message-State: ALyK8tIwY2B/yyWZVAVJyN9AbUSyBb63m+PtnaUiEfvE/yKgUg8N7cbqwW6Wmz8zVnUizIMpZQl/MmMUW5e6lw== MIME-Version: 1.0 X-Received: by 10.36.47.136 with SMTP id j130mr375420itj.48.1464893763690; Thu, 02 Jun 2016 11:56:03 -0700 (PDT) Received: by 10.107.37.138 with HTTP; Thu, 2 Jun 2016 11:56:03 -0700 (PDT) In-Reply-To: <5C676E6359909E478C7B811BDB48CA354A06A6@CWWAPP478.windstream.com> References: <5C676E6359909E478C7B811BDB48CA354A06A6@CWWAPP478.windstream.com> Date: Thu, 2 Jun 2016 14:56:03 -0400 Message-ID: Subject: Re: Looping through a hashmap & removing elements From: Guy Matz To: users@groovy.apache.org Content-Type: multipart/alternative; boundary=001a114417fe6b38540534502820 archived-at: Thu, 02 Jun 2016 18:56:16 -0000 --001a114417fe6b38540534502820 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Ahh!! I only saw this removeAll: public boolean *removeAll*(Object[] items) !! Thanks!!! On Thu, Jun 2, 2016 at 2:27 PM, Winnebeck, Jason < Jason.Winnebeck@windstream.com> wrote: > If you want to actually edit the original map: > > > > def uidMap =3D [ > > a: 123, > > b: 456, > > c: 789 > > ] > > > > uidMap.entrySet().removeAll { it.key.startsWith('a') } > > > > If you want a new map, emmanuel=E2=80=99s solution using findAll is best. > > > > Jason > > > > *From:* Guy Matz [mailto:guymatz@gmail.com] > *Sent:* Thursday, June 02, 2016 2:18 PM > *To:* users@groovy.apache.org > *Subject:* Looping through a hashmap & removing elements > > > > Hi! I want to loop through a hashmap and delete some elements based on > some criteria . . . I thought there would be some slick groovy method - = in > the spirit of findAll, etc. - to do this, but couldn't find it . . . my > java developer workmate suggested: > > > > iter =3D uidMap.entrySet().iterator() > *while *(iter.hasNext()) { > entry =3D iter.next() > key =3D entry.key > value =3D entry.value > > if (bla, blah, blah) { > > iter.remove() > > } > > > > Is there a groovier way? > > > > Thanks! > > Guy > > ------------------------------ > This email message and any attachments are for the sole use of the > intended recipient(s). Any unauthorized review, use, disclosure or > distribution is prohibited. If you are not the intended recipient, please > contact the sender by reply email and destroy all copies of the original > message and any attachments. > --001a114417fe6b38540534502820 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Ahh!!=C2=A0 I only saw this removeAll:

public bool= ean removeAll(Object[] items)


!!=C2=A0 Thanks!!!

On Thu, Jun 2, 2016 at 2:27 PM, Win= nebeck, Jason <Jason.Winnebeck@windstream.com> = wrote:

If you want to actually edit the orig= inal map:

=C2=A0

def uidMap =3D [=

=C2=A0 a: 123,

=C2=A0 b: 456,

=C2=A0 c: 789

]

=C2=A0

uidMap.entrySet().removeAll { it.key.= startsWith('a') }

=C2=A0

If you want a new map, emmanuel=E2=80= =99s solution using findAll is best.

=C2=A0

Jason

=C2=A0

From: Guy Matz [mailto:guymatz@gmail.com]
Sent: Thursday, June 02, 2016 2:18 PM
To: use= rs@groovy.apache.org
Subject: Looping through a hashmap & removing elements=

=C2=A0

Hi!=C2=A0 I want to loop through a hashmap and delet= e some elements based on some criteria . . .=C2=A0 I thought there would be= some slick groovy method - in the spirit of findAll, etc. - to do this, bu= t couldn't find it . . . =C2=A0my java developer workmate suggested:

=C2=A0

iter =3D uidMap.entrySet().iterator()
while (iter.hasNext()) {
=C2= =A0=C2=A0=C2=A0 entry =3D iter.next()
=C2=A0=C2=A0=C2=A0 key =3D entry.k= ey
=C2=A0=C2=A0=C2=A0 value =3D entry.value
=C2=A0=C2=A0=C2=A0 if (bla, blah, b=
lah) {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 iter.remove()
=C2=A0=C2=A0=C2=A0 }
=C2=A0
Is there a groovier way?
=C2=A0
Thanks!
Guy

This email message and any attachments are for the sole use of the inte= nded recipient(s). Any unauthorized review, use, disclosure or distribution= is prohibited. If you are not the intended recipient, please contact the s= ender by reply email and destroy all copies of the original message and any= attachments.

--001a114417fe6b38540534502820--