Skip to content

Commit 43250b4

Browse files
author
Glen K. Peterson
committed
Inside PersistentTreeMap, Made Red and Black extend Tuple2 instead of having different subclasses based on whether they just held a key (for TreeSet) or also a value (for TreeMap). Timed this change and found no performance difference. This made the returned Entries easily and quickly serializable (after making the left and right fields transient). Added ImUnsortSet, ImUnsortSetTrans, and ImListTrans interfaces to expose the Transient implementations. Added CodeStylePaguro.xml for instant consistent code style. Improved test coverage for TreeMap. Cleaned up change log. Added epl-v10.html Clojure collection license in accordance with its terms. Bumped version number to 2.0.4. Reused PersistentTreeMap.Box in PersistentHashMap and documented its (weird) usage.
1 parent fa9646b commit 43250b4

16 files changed

+764
-473
lines changed

CHANGE_LOG.md

+64-67
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,50 @@
1-
# Upgrade from 1.x to 2.0.3
2-
3-
Anything that used to be implemented as an anonymous class, object, or lambda is now
4-
implemented as an enum or serializable sub-class. As a result, the following constants have moved.
5-
The easiest way to make this change is to use a static import for the new fields. For example:
6-
```java
7-
// Obsolete:
8-
import static org.organicdesign.fp.function.Function1..*;
9-
10-
// New:
11-
import static org.organicdesign.fp.function.Function1.ConstBool.*;
12-
```
13-
14-
##### List of changes:
15-
```
16-
org.organicdesign.fp.collections.Equator:
17-
DEFAULT_COMPARATOR is now Comp.DEFAULT
18-
DEFAULT_EQUATOR is now Equat.DEFAULT
19-
ComparisonContext moved to org.organicdesign.fp.collections.ComparisonContext
20-
DEFAULT_CONTEXT is now org.organicdesign.fp.collections.ComparisonContext.CompCtx.DEFAULT
21-
22-
org.organicdesign.fp.collections.RangeOfInt:
23-
LIST_EQUATOR is now Equat.LIST
24-
25-
org.organicdesign.fp.function.Function0:
26-
NULL is now Const.NULL
27-
New serializable sub-class for functions that always return the same value:
28-
Constant (Function0.Constant)
29-
30-
org.organicdesign.fp.function.Function1
31-
IDENTITY is now Const.IDENTITY
32-
ACCEPT is now ConstBool.ACCEPT
33-
REJECT is now ConstBool.REJECT
34-
35-
org.organicdesign.fp.collections.UnmodMap.UnEntry.entryToUnEntry(Map.Entry<K,V> entry)
36-
is now
37-
org.organicdesign.fp.tuple.Tuple2.of(Map.Entry<K,V> entry)
38-
```
1+
# Change Log
392

40-
#### Additional changes
41-
- Tuples all implement Serializable. I really struggled over this, but in the end decided it's better
42-
to have all tuples serializable than to make anyone write a serialization proxy on a subclass because
43-
tuples *aren't* serializable. It boils down to Serializable assuming mutability and wanting a
44-
zero-arg constructor and mutable fields on the parent class in order to deserialize the child class.
45-
I wasn't willing to do that.
46-
- Removed UnmodMap.UnEntry.entryToUnEntry(Map.Entry<K,V> entry).
47-
- PersistentHashMap.ArrayNode, .BitMapIndexNode, .HashCollisionNode, and .NodeIter are now all private (were public or package).
48-
There should never have been any reason to use or access these.
49-
- Added ImSetTrans&lt;E&gt; interface and exposed the Transient Set implementation.
50-
- Added ImListTrans&lt;E&gt; interface and exposed the Transient Vector implementation.
3+
## 2016-09-10 Release 2.0.4: Serializable (Part 4)
4+
- Made PersistentTreeMap return serializable Tuple2's. Actually these are subclasses of internal nodes that still contain
5+
big chunks of the treemap, but those chunks are transient (not serializable) and private.
6+
When deserialized, they become plain old Tuple2's.
7+
- Speed is unchanged after this: 10-item maps/sets are 0-3% faster, but generally near the margin of error for equal speed.
8+
Large maps/sets (100K elements) are 0-1% slower; within the margin of error.
9+
- Added ImUnsortSet and ImUnsortSetTrans interfaces to expose the TransientSet implementation.
10+
- Added ImListTrans interface to expose the Transient Vector implementation.
11+
- Radically improved test coverage of PersistentTreeMap and slightly improved PersistentHashMap
12+
- Added epl-v10.html referenced in Rich's comments. Should have read the legal terms more carefully earlier.
13+
- Added CodeStylePaguro.xml for Idea to import.
5114
- Found some opportunities to use transient implementations more efficiently.
52-
- Static method UnmodSortedIterable.equals() has been deprecated (renamed to UnmodSortedIterable.equal() to avoid confusion with Object.equals()).
5315

54-
#### What's *NOT* Serializable?
55-
- The function interfaces (Function0, Function1, etc.) will *NOT* implement Serializable.
56-
These interfaces are general and Serializable is too much for implementers to think about (and often irrelevant).
57-
However, the *constants* and *singletons* in those interfaces have been changed to implement
58-
Serializable.
59-
- Iterators are *NOT* serializable. They aren't in java.util.Collections either.
60-
If you need an iterator to be serializable for some reason, open an issue and we'll discuss it.
61-
- Transformable is not serializable.
62-
- Transient-HashSet, -HashMap, and -Vector are not Serializable.
16+
#### Still *NOT* Serializable
6317
- FunctionUtils.unmodifiable___() methods are not serializable (yet?).
18+
- Transformable is not serializable (should it be?)
6419

6520
Issues? Questions? Provide feedback on the [Serialization enhancement request](https://github.com/GlenKPeterson/UncleJim/issues/10)
6621

67-
68-
# Change Log
69-
70-
## 2016-09-10 Release 2.0.3
22+
## 2016-09-10 Release 2.0.3: Serializable (Part 3)
23+
- Reverted the most serious breaking changes from previous 2.0.x releases.
24+
Going from 1.x to 2.0.3+ in the two projects I use Paguro in, no changes were necessary.
25+
- Tuples all implement Serializable.
26+
Serializable wants a zero-arg constructor and mutable fields on the parent class in order to deserialize the child class.
27+
That's the opposite of what this project is about.
28+
Better to have all tuples serializable than to make anyone write a serialization proxy on a subclass because tuples *aren't* serializable.
29+
This also means that Tuple2 can still implement Map.Entry, which gets rid of the breaking changes in 2.0.0, .1, and .2.
7130
- Changed serialized form of RangeOfInt to just serialize the start and end,
7231
then calculate the size from that.
7332
- Removed KeyVal class and made Tuples serializable instead. Back to using tup() instead of kv()
7433
- Static method UnmodSortedIterable.equals() has been deprecated (renamed to UnmodSortedIterable.equal() to avoid confusion with Object.equals()).
7534

76-
## 2016-09-01 Release 2.0.2 USE 2.0.3 INSTEAD!
35+
## 2016-09-01 Release 2.0.2: USE 2.0.3+ INSTEAD!
7736
- Gave 5 main collections custom serialized forms (after reading Josh Bloch) so that we can change
7837
the implementations later without breaking any clients who are using them for long-term storage.
7938
- Decided *NOT* to make any itera**tors** serializable.
8039
- Improved tests a bit, especially for serialization.
8140

82-
## 2016-09-01 Release 2.0.1 USE 2.0.3 INSTEAD!
41+
## 2016-09-01 Release 2.0.1: USE 2.0.3+ INSTEAD!
8342
- Made UnmodSortedIterable.castFrom... methods generic and serializable (and wrote tests for same).
8443
- Fixed some Javadoc link errors.
8544

86-
## 2016-08-27 Release 2.0.0: USE 2.0.3 INSTEAD!
87-
This is a major release due to the following **breaking changes** in order to make more things serializable without creating a mess:
45+
## 2016-08-27 Release 2.0.0: USE 2.0.3+ INSTEAD - ALL SIGNIFICANT BREAKING CHANGES WERE REVERTED!
46+
This is a major release due to making a new serializable format.
47+
- Anything that used to be implemented as an anonymous class, object, or lambda is now implemented as an enum or serializable sub-class.
8848
- Hash codes of all tuples are now calculated by adding together the hash codes of all member items.
8949
They used to bitwise-or the first two items for compatibility with Map.Entry.
9050
- Tuple2 no longer implements Map.Entry or UnmodMap.UnEntry. Instead, a new class KeyVal extends Tuple2, Map.Entry, UnmodMap.UnEntry, and Serializable.
@@ -95,6 +55,8 @@ This is a major release due to the following **breaking changes** in order to ma
9555
- Moved ComparisonContext interface from inside the Equator interface, to it's own file: org.organicdesign.fp.ComparisonContext.
9656
- Replaced Equator.ComparisonContext.DEFAULT_CONTEXT with ComparisonContext.CompCtx.DEFAULT
9757
- KeyVal.toString() is now kv(k,v) like all the other Java toString methods.
58+
- PersistentHashMap.ArrayNode, .BitMapIndexNode, .HashCollisionNode, and .NodeIter are now all private (were public or package).
59+
There should never have been any reason to use or access these.
9860

9961
This release also contains the following non-breaking changes:
10062
- Made serializable: Persistent- HashMap, HashSet, TreeMap, TreeSet, Vector. RangeOfInt,
@@ -105,6 +67,41 @@ This release also contains the following non-breaking changes:
10567

10668
Note: Xform is NOT serializable. I don't know yet whether that's good or bad.
10769

70+
##### Moved items in 2.0:
71+
```
72+
org.organicdesign.fp.collections.Equator:
73+
DEFAULT_COMPARATOR is now Comp.DEFAULT
74+
DEFAULT_EQUATOR is now Equat.DEFAULT
75+
ComparisonContext moved to org.organicdesign.fp.collections.ComparisonContext
76+
DEFAULT_CONTEXT is now org.organicdesign.fp.collections.ComparisonContext.CompCtx.DEFAULT
77+
78+
org.organicdesign.fp.collections.RangeOfInt:
79+
LIST_EQUATOR is now Equat.LIST
80+
81+
org.organicdesign.fp.function.Function0:
82+
NULL is now Const.NULL
83+
New serializable sub-class for functions that always return the same value:
84+
Constant (Function0.Constant)
85+
86+
org.organicdesign.fp.function.Function1
87+
IDENTITY is now Const.IDENTITY
88+
ACCEPT is now ConstBool.ACCEPT
89+
REJECT is now ConstBool.REJECT
90+
91+
org.organicdesign.fp.collections.UnmodMap.UnEntry.entryToUnEntry(Map.Entry<K,V> entry)
92+
is now
93+
org.organicdesign.fp.tuple.Tuple2.of(Map.Entry<K,V> entry)
94+
```
95+
96+
##### Not Serializable (and will probably never be)
97+
- The function interfaces (Function0, Function1, etc.) will *NOT* implement Serializable.
98+
These interfaces are general and Serializable is too much for implementers to think about (and often irrelevant).
99+
However, the *constants* and *singletons* in those interfaces have been changed to implement
100+
Serializable.
101+
- Iterators are *NOT* serializable. They aren't in java.util.Collections either.
102+
If you need an iterator to be serializable for some reason, open an issue and we'll discuss it.
103+
- Transient-HashSet, -HashMap, and -Vector are not Serializable.
104+
108105
## 2016-03-23 Release 1.0.3
109106
- Fixed error message for Xform.drop() to "Can't drop less than zero items #6." Thanks @pniederw
110107
- Fixed "Wrong bounds check in UnmodList.listIterator #7." Thanks @pniederw

CodeStylePaguro.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<code_scheme name="CodeStylePaguro">
2+
<option name="RIGHT_MARGIN" value="100" />
3+
<option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
4+
<option name="JD_LEADING_ASTERISKS_ARE_ENABLED" value="false" />
5+
<JavaCodeStyleSettings>
6+
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
7+
</JavaCodeStyleSettings>
8+
<MarkdownNavigatorCodeStyleSettings>
9+
<option name="RIGHT_MARGIN" value="72" />
10+
</MarkdownNavigatorCodeStyleSettings>
11+
<codeStyleSettings language="JAVA">
12+
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
13+
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
14+
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
15+
<option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
16+
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
17+
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" />
18+
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
19+
<option name="ALIGN_MULTILINE_METHOD_BRACKETS" value="true" />
20+
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
21+
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
22+
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
23+
<option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
24+
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
25+
<option name="KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE" value="true" />
26+
<option name="WRAP_LONG_LINES" value="true" />
27+
</codeStyleSettings>
28+
</code_scheme>

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ UncleJim ("**Un**modifiable **Coll**ections for **J**ava™ **Imm**utability") p
22

33
#News
44

5-
##2016-09-06 Release 2.0.3: Serializable
6-
**DO NOT USE Releases 2.0.0 - 2.0.2. Breaking changes from these were reverted.**
7-
Thanks @sblommers for spotting the lack of serialization and writing the key unit test!
8-
Fixing this involved some minor breaking changes. Please see the [Upgrade Notes in the Change Log](https://github.com/GlenKPeterson/UncleJim/blob/master/CHANGE_LOG.md#upgrade-from-1x-to-2x) for details.
5+
##2016-09-06 Release 2.0.4: Serializable (Part 4)
6+
**DO NOT USE Releases 2.0.0 - 2.0.2 because breaking changes from these releases were reverted.**
7+
Full notes in the [Change Log](https://github.com/GlenKPeterson/UncleJim/blob/master/CHANGE_LOG.md).
98

109
###Renaming
1110
This project will soon be renamed to "Paguro" ("pah-GUH-row" rhymes with "furrow") which is short for the Latin "Paguroidea" - the name of the Hermit Crab superfamily in Biology. These collections grow by adding a new shell, leaving the insides the same, much the way Hermit Crabs trade up to a new shell when they grow. Plus, hermit crabs are cute.
@@ -47,7 +46,7 @@ Available from the [Maven Repository](http://mvnrepository.com/artifact/org.orga
4746
<groupId>org.organicdesign</groupId>
4847
<!-- NOTE: artifactId will change to "Paguro" in November 2016 -->
4948
<artifactId>UncleJim</artifactId>
50-
<version>2.0.3</version>
49+
<version>2.0.4</version>
5150
</dependency>
5251
```
5352

0 commit comments

Comments
 (0)