1-million-row ListView

断了今生、忘了曾经 提交于 2019-12-07 04:25:03

问题


I have a SysListView32 that should potentially host millions of rows, and three columns of text A, B, C each < 256 characters.

Let's say column B has many many repetitions (example: column A is filename, column B is path, and each row is a file of the filesystem), and has only 100k different values (instead of several millions).

Is it possible to avoid duplication in RAM of content of column B of the ListView GUI element?

Can we fill a ListView with only pointers to arrays elements (taken from the 100k-element-array of different values of column B), instead of duplicated data?

How to modify this to make it work?

LV_ITEM item;
item.mask = LVIF_TEXT;
item.pszText = "Hello";
...
ListView_SetItem(hList, &item);

回答1:


What you need is also referred as "Virtual List". A virtual list control is a list view control that has the LVS_OWNERDATA style. This style enables the control to support an item count up to a DWORD (the default item count only extends to an int). However, the biggest advantage provided by this style is the ability to only have a subset of data items in memory at any one time. This allows the virtual list view control to lend itself for use with large databases of information, where specific methods of accessing data are already in place. For a given set of data (list or dynamic array), you need to follow these steps:

  1. Add LVS_OWNERDATA style to your ListView
  2. Make a call to CListCtrl::SetItemCount passing the data source size, like std::vector::size().
  3. Catch the LVN_GETDISPINFO notification. This is where the data is rendered into the ListCtrl.

Please have a look at the attached links I added, for more information and sample code. If you use CListView you can have access to the CListCtrl with GetListCtrl.

Links:

Virtual List Controls

Using virtual lists



来源:https://stackoverflow.com/questions/44790632/1-million-row-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!