You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles (JIRA)" <ji...@apache.org> on 2010/11/05 13:19:43 UTC
[jira] Created: (MATH-432) Create a "Pair" class
Create a "Pair" class
---------------------
Key: MATH-432
URL: https://issues.apache.org/jira/browse/MATH-432
Project: Commons Math
Issue Type: New Feature
Reporter: Gilles
Assignee: Gilles
Fix For: 3.0
The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MATH-432) Create a "Pair" class
Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928899#action_12928899 ]
Paul Benedict commented on MATH-432:
------------------------------------
Commons Lang 3.0 includes a Pair<K,V> class:
http://commons.apache.org/lang/api-3.0-beta/org/apache/commons/lang3/Pair.html
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MATH-432) Create a "Pair" class
Posted by "Gilles (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928667#action_12928667 ]
Gilles commented on MATH-432:
-----------------------------
In fact, it is the other way around, I didn't need "Pair" because I intended to reuse "AbstractMap.Entry".
Implementing "Map.Entry" would have been a reminder to revert the "sortInplace" to use that one, once CM targets Java 1.6 ;-).
However, apart from that, I don't have a preference. We could indeed have an immutable "Pair".
If everyone agrees, I can do the change.
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MATH-432) Create a "Pair" class
Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928684#action_12928684 ]
Luc Maisonobe commented on MATH-432:
------------------------------------
Yes, immutable objects are always much safer.
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MATH-432) Create a "Pair" class
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928856#action_12928856 ]
Sebb commented on MATH-432:
---------------------------
A Pair implementation which has mutable fields won't be inherently thread-safe even if the parameters are immutable.
Whereas a Pair implementation that has final fields will at least be thread-safe if the parameters are immutable.
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MATH-432) Create a "Pair" class
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928951#action_12928951 ]
Sebb commented on MATH-432:
---------------------------
True, but MATH does not depend on any other libraries at present.
The class is only needed for keeping track of items as part of the sort, so a simple immutable local class seems the best approach.
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MATH-432) Create a "Pair" class
Posted by "Gilles (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12928821#action_12928821 ]
Gilles commented on MATH-432:
-----------------------------
Since we don't make _copies_ of the key and value passed to the constructor, the references are shared by the arguments and the instances variables of the newly-created {{Pair}}. Assuming that the object is immutable (and documenting it as such) may thus give a false sense of safety.
Is changing the code still worth it?
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Reopened: (MATH-432) Create a "Pair" class
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sebb reopened MATH-432:
-----------------------
I'm not sure why one needs to implement Map.Entry for this purpose, rather than just implementing a plain Pair.
AFAICT, the code does not need the mutability of Map.Entry, so why not use an immutable Pair class?
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (MATH-432) Create a "Pair" class
Posted by "Gilles (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gilles resolved MATH-432.
-------------------------
Resolution: Fixed
Implemented in revision 1031574.
The usage of {{AbstractMap.SimpleEntry}} has been replaced by {{Pair}} in revision 1031581.
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (MATH-432) Create a "Pair" class
Posted by "Gilles (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gilles resolved MATH-432.
-------------------------
Resolution: Fixed
Modified as suggested (revision 1032010).
> Create a "Pair" class
> ---------------------
>
> Key: MATH-432
> URL: https://issues.apache.org/jira/browse/MATH-432
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Gilles
> Assignee: Gilles
> Fix For: 3.0
>
>
> The {{AbstractMap.SimpleEntry}} implementation of {{Map.Entry<K,V>}} is only available in Java 1.6+.
> I propose to create a class Pair<K,V> to be used as a replacement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.