Re: when will Tuple be std?



apm35@xxxxxxxxxxxxxxxxxx wrote:
I have the need for a Tuple in my java program and hoped it would be
there as std. I cannot find it.

A sexually-transmitted disease?

I have found the project, http://javatuple.com/index.shtml, which is
useful and encouraging, but I wonder how long it will be before Tuple
is std.

Never, but it only takes about ten minutes to write one.

public class Pair <T, U>
{
private final T first;
private final U second;
public Pair ( T t, U u )
{
first = t;
second = u;
}
public final T getFirst() { return first; }
public final U getSecond() { return second; }

@SuppressWarnings ("unchecked" )
@Override public boolean equals( Object oth )
{
if ( this == oth ) { return true; }
if ( ! (oth instanceof Pair) ) { return false; }
Pair <T, U> pair = (Pair<T, U>) oth;
return (first == null? pair.first == null : first.equals( pair.first ))
&& (second == null? pair.second == null : second.equals( pair.second ));
}
@Override public int hashCode()
{
return first.hashCode() * 31 + second.hashCode();
}
}

There you go, all your googling satisfied.

--
Lew
.



Relevant Pages

  • Re: Frying and egg
    ... get the time or the cricket scores, ... for STD calls so I found I could get the cricket by putting an STD ... department's responsibility to look out for excessive private use. ... The university's phone system allowed direct dialling ...
    (alt.usage.english)
  • Re: New mobile phone scam?
    ... I called back and got message sorry this is private number ... should have googled the std (funny that... ... transmitted disease) prefix first ...
    (uk.legal)
  • Re: New mobile phone scam?
    ... I called back and got message sorry this is private number ... should have googled the std (funny that... ... transmitted disease) prefix first ...
    (uk.legal)