treemap

Scala 2.8 TreeMap and custom Ordering

為{幸葍}努か 提交于 2019-12-03 07:34:08
I'm switching from scala 2.7 and ordered to scala 2.8 and using ordering. It looks quite straight forward but I was wondering could I make it a little less verbose. For example: scala> case class A(i: Int) defined class A scala> object A extends Ordering[A] { def compare(o1: A, o2: A) = o1.i - o2.i} defined module A If I then try to create a TreeMap I get an error scala> new collection.immutable.TreeMap[A, String]() <console>:10: error: could not find implicit value for parameter ordering: Ordering[A] new collection.immutable.TreeMap[A, String]() ^ However if I explicitly specify the object A

how to encode this data to parent / children structure in JSON

偶尔善良 提交于 2019-12-03 07:14:31
问题 I am working with d3.js to visualise families of animals (organisms) (up to 4000 at a time) as a tree graph, though the data source could just as well be a directory listing, or list of namespaced objects. my data looks like: json = { organisms:[ {name: 'Hemiptera.Miridae.Kanakamiris'}, {name: 'Hemiptera.Miridae.Neophloeobia.incisa'}, {name: 'Lepidoptera.Nymphalidae.Ephinephile.rawnsleyi'}, ... etc ... ] } my question is: I am trying to find the best way to convert the above data to the

Creating a custom d3 layout

旧城冷巷雨未停 提交于 2019-12-03 05:48:40
I need to create a custom d3 layout that is somewhat close to a treemap but in a triangular style. Here's a screenshot so that you can understand: Pyramid layout As you can see, it works pretty neat and fits my need. To code it, i've based the code on the treemap layout code: d3.layout.pyramid= function () { var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = 0; function populate (nodes, currentHeight, currentHeightPadded, currentBase, currentSumedWeight) { ... } function populate_layers (layer, nodes,currentHeight,currentLength, currentSumedArea

HashTable vs HashMap vs TreeMap

橙三吉。 提交于 2019-12-03 05:17:18
HashMap是HashTable的轻量级实现(非线程安全),HashMap可以通过collections.synchronizedMap()来达到同步效果。 HashTable:contains,HashMap:containsKey、containsValue HashMap允许有一条记录的键为null,HashTable不允许。 HashTable中hash数据默认大小为11,增加方式是old*2+1。在HashMap中,hash数组的默认大小是16,而且一定是2的指数。 hash值的使用不同,HashTable直接使用对象的hashCode TreeMap实现SortMap接口,把保存的记录按键来排序。 来源: oschina 链接: https://my.oschina.net/u/4045381/blog/3077535

Visual Treemap in Winforms

六月ゝ 毕业季﹏ 提交于 2019-12-03 03:11:33
Are there any frameworks for building squarified treemaps in C# 2.0 WinForms? Something similar to this: (from http://www.codeproject.com/KB/recipes/treemaps.aspx ) Microsoft Research put one together. Don't know how easy it is use. http://research.microsoft.com/en-us/downloads/dda33e92-f0e8-4961-baaa-98160a006c27/default.aspx I know you asked about WinForms, but I'm sure someone will hit this page when searching for WPF tree maps. This currently seems to be the best WPF freebie out there, though I found a few minor issues with it, it's still pretty good: http://treemaps.codeplex.com/ Check

Java 集合系列-第八篇-Map架构

倾然丶 夕夏残阳落幕 提交于 2019-12-03 01:53:46
Map架构 Map 是映射接口,Map中存储的内容是键值对(key-value)。 AbstractMap 是继承于Map的抽象类,它实现了Map中的大部分API。其它Map的实现类可以通过继承AbstractMap来减少重复编码。 SortedMap 是继承于Map的接口。SortedMap中的内容是排序的键值对,排序的方法是通过比较器(Comparator)。 NavigableMap 是继承于SortedMap的接口。相比于SortedMap,NavigableMap有一系列的导航方法;如"获取大于/等于某对象的键值对"、“获取小于/等于某对象的键值对”等等。 TreeMap 继承于AbstractMap,且实现了NavigableMap接口;因此,TreeMap中的内容是“有序的键值对”! HashMap 继承于AbstractMap,但没实现NavigableMap接口;因此,HashMap的内容是“键值对,但不保证次序”! Hashtable 虽然不是继承于AbstractMap,但它继承于Dictionary(Dictionary也是键值对的接口),而且也实现Map接口;因此,Hashtable的内容也是“键值对,也不保证次序”。但和HashMap相比,Hashtable是线程安全的,而且它支持通过Enumeration去遍历。 WeakHashMap

how to encode this data to parent / children structure in JSON

点点圈 提交于 2019-12-02 22:05:50
I am working with d3.js to visualise families of animals (organisms) (up to 4000 at a time) as a tree graph, though the data source could just as well be a directory listing, or list of namespaced objects. my data looks like: json = { organisms:[ {name: 'Hemiptera.Miridae.Kanakamiris'}, {name: 'Hemiptera.Miridae.Neophloeobia.incisa'}, {name: 'Lepidoptera.Nymphalidae.Ephinephile.rawnsleyi'}, ... etc ... ] } my question is: I am trying to find the best way to convert the above data to the hierarchical parent / children data structure as is used by a number of the d3 visualisations such as

Best way to store Country codes, names, and Continent in Java

北战南征 提交于 2019-12-02 21:10:28
I want to have a List or Array of some sort, storing this information about each country: 2 letter code Country name such as Brazil Continent/region of the world such as Eastern Europe, North America, etc. I will classify each country into the region/continent manually (but if there exists a way to do this automatically, do let me know). This question is about how to store and access the countries. For example, I want to be able to retrieve all the countries in North America. I don't want to use local text files or such because this project will be converted to javascript using Google Web

重新认识TreeMap

馋奶兔 提交于 2019-12-02 20:27:07
特点 TreeMap 类不仅实现了 Map 接口,还实现了 Map 接口的子接口 java.util.SortedMap 。由 TreeMap 类实现的 Map 集合,不允许键对象为 null 。 核心 红黑树 比较器实现大小比较。 红黑树 一种平衡二叉树的实现。 比较器 由于 TreeMap 需要排序,所以需要一个 Comparator 为键值进行大小比较.当然也是用 Comparator 定位的. Comparator 可以在创建 TreeMap 时指定 如果创建时没有确定,那么就会使用 key.compareTo() 方法,这就要求 key 必须实现 Comparable 接口. TreeMap 是使用Tree数据结构实现的,所以使用 compare 接口就可以完成定位了. put方法 public V put(K key, V value) { Entry<K,V> t = root; if (t == null) { compare(key, key); // type (and possibly null) check root = new Entry<>(key, value, null); size = 1; modCount++; return null; } int cmp; Entry<K,V> parent; // split comparator and

How do I omit labels in the R treemap?

為{幸葍}努か 提交于 2019-12-02 14:06:44
问题 I've been using the R treemap package and I have a treemap that's 2 levels deep. I want the second level labels to be printed but not the first. Using the example in the man page: tmPlot(GNI2010, index=c("continent", "iso3"), vSize="population", vColor="GNI", type="value") treemap example http://www.eecs.tufts.edu/~rveroy/stuff/GNI2010-treemap.png I want to get rid of the continent labels, but retain the iso3 labels. I apologize in advance if it is in the documents but haven't found it. 回答1: