Re: Possible addition of a default 'getOne' method on Iterable?

2018-01-30 Thread Dave Brosius
Basically, but it's annoying and ugly to write most likely sub-optimal has problems with things like synchronized collections On 01/31/2018 12:28 AM, Zheka Kozlov wrote: Isn't iterable.getOne() the same as iterable.iterator().next()? 2018-01-31 12:15 GMT+07:00 Dave Brosius <db

Possible addition of a default 'getOne' method on Iterable?

2018-01-30 Thread Dave Brosius
Greetings, sorry if this has been asked before, but has there been any consideration for adding a default T getOne() {     Iterator it = iterator();     if (!it.hasNext()) {     throw new NoSuchElementException();     }     return it.next(); } on the Iterable interface? It is often

Re: java.util.Pair

2017-07-13 Thread Dave Brosius
I would avoid Pair and Entry like the plague. They are devoid of meaning and are just there to save your fingers. If that is your main impetus, i'd just turn to using lombok and have true bean classes, that are finger-cost free. On 07/13/2017 05:41 PM, fo...@univ-mlv.fr wrote: De: "John

Soften interface for javax.management.ObjectName.getInstance and friends

2017-02-23 Thread Dave Brosius
Greetings. the method public static ObjectName getInstance(String domain, Hashtable table) throws MalformedObjectNameException { return new ObjectName(domain, table); } in javax.management.ObjectName allows for a provided Hashtable to specify properties for

Re: Make iterators cloneable?

2016-09-12 Thread Dave Brosius
That would give you unwanted duplicates Fi-Fum and Fum-Fi for instance On 09/11/2016 08:58 PM, Tagir Valeev wrote: Actually given the fact that we're iterating the Set (so the elements are unique) and using the assumption that iteration of the same set is stable, you can avoid numbering

Re: Make iterators cloneable?

2016-09-11 Thread Dave Brosius
Sure, but both of those algorithms are n^2, which is a bit painful, especially given all the pointer chasing that occurs with iterators. On 09/11/2016 08:20 AM, Peter Levart wrote: Hi, Even if the elements are not comparable, you could rely on the fact that Collection(s) usually create

Re: Make iterators cloneable?

2016-09-11 Thread Dave Brosius
because any JITs routinely devirtualize this kind of call). cheers, Rémi - Mail original - De: "Dave Brosius" <dbros...@mebigfatguy.com> À: "Louis Wasserman" <lowas...@google.com>, "Jonathan Bluett-Duncan" <jbluettdun...@gmail.com> Cc: co

Re: Make iterators cloneable?

2016-09-10 Thread Dave Brosius
for long enough there are Iterator implementations out there that aren't cloneable -- say, Iterators reading from a BufferedReader, where there really won't be any way to do what you're hoping for; BufferedReaders certainly aren't cloneable. On Sat, Sep 10, 2016 at 4:33 PM Dave Brosius <dbros

Re: Make iterators cloneable?

2016-09-10 Thread Dave Brosius
= Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); s.add("Fee"); s.add("Fi"); s.add("Fo"); s.add("Fum"); for (String v1 : s) { for (String v2 : s) {System.out.println(v1 + "<-->" +

Make iterators cloneable?

2016-09-10 Thread Dave Brosius
It would be nice to be able to associate each element in a collection with another element in the collection, which is something very easily done with index based collections, but with sets, etc this isn't so easy... unless i'm having a brainfart. So i'd like to do this, but Iterator doesn't

Deprecation of String(String) constructor

2016-09-05 Thread Dave Brosius
Hi Folks, I notice in that the String (String original) constructor as seen here

Re: RFR(m): 8145468u1 deprecations for java.lang

2016-04-17 Thread Dave Brosius
Greetings, Along these lines, is there a reason not to deprecate the String(String s) constructor? Now that substring doesn't glom off the original string, i see no reason for this constructor. -dave On 04/15/2016 06:36 PM, Stuart Marks wrote: Hi all, Here's a small update to the jdk

Match.appendReplacement with StringBuilder

2016-03-03 Thread Dave Brosius
Greetings, It would be nice if java.util.regex.Matcher had a replacement for Matcher appendReplacement(StringBuffer sb, String replacement) StringBuffer appendTail(StringBuffer sb) That took StringBuilder.

ExceptionTable addition?

2015-12-14 Thread Dave Brosius
Greetings, From a byte code analysis--toolsy point of view, it would be nice if you could deterministically find the end of a catch/finally block. Unfortunately, the ExceptionTable attribute only lists the starts of trys/catches/finallys. Now obviously, there are times when you can