15
décembre
2011
décembre
2011


Je me suis amusé à regarder les collections que propose Guava sous forme de factories statiques.
Pour les listes, c’est un peu pauvre. Il n’y a que les ArrayList et les LinkedList. A-t-on néanmoins besoin d’autre chose ?
1 2 | List<String> list1 = Lists.newArrayList(); List<String> list2 = Lists.newLinkedList(); |
Avec les sets, on a un peu plus de choix.
1 2 3 4 | Set<String> set1 = Sets.newHashSet(); Set<String> set2 = Sets.newIdentityHashSet(); Set<String> set3 = Sets.newLinkedHashSet(); Set<String> set4 = Sets.newTreeSet(); |
Et c’est avec les maps qu’on s’amuse le plus.
1 2 3 4 5 | Map<String, String> map1 = Maps.newConcurrentMap(); Map<String, String> map2 = Maps.newHashMap(); Map<String, String> map3 = Maps.newIdentityHashMap(); Map<String, String> map4 = Maps.newLinkedHashMap(); Map<String, String> map5 = Maps.newTreeMap(); |
Je n’ai pris en compte que les factories sans argument. Je ne me suis pas occupé des builders (nombreux dans la librairie)
Commentaires récents
- Le Stop watch de Guava dans
- Le Stop watch de Guava dans
- Le Stop watch de Guava dans