arraylist

VBA memory size of Arrays and Arraylist

穿精又带淫゛_ 提交于 2019-12-20 04:48:31
问题 I have tried to load 6.000.000 (6 mio) strings of 64 characters in length in order to sort them in VBA. What I have noticed is : 1. When I use an Array the memory occupied is around 916 MB 2. When I use an ArrayList the memory occupied goes to 1.105 MB None of them is reasonable to me as the strings size is around 380 MB. What I doing wrong ? As the numbers of strings will grow rapidly I will face 'Out of memory' very soon. Any idea will be welcome. Demetres 回答1: Most of the issue is the fact

java.lang.IndexOutOfBoundsException

两盒软妹~` 提交于 2019-12-20 04:30:26
问题 I use ArrayList to store the 'shadows' for every rectangle in the level but when I iterate through the like this: for(int n = 0; n < shadows.size(); ++n){ g2d.fillPolygon(shadows.get(n)[0]); g2d.fillPolygon(shadows.get(n)[1]); g2d.fillPolygon(shadows.get(n)[2]); g2d.fillPolygon(shadows.get(n)[3]); g2d.fillPolygon(shadows.get(n)[4]); g2d.fillPolygon(shadows.get(n)[5]); } I get a java.lang.IndexOutOfBoundsException error that looks like this: Exception in thread "AWT-EventQueue-0" java.lang

Java Arraylist Data extraction

强颜欢笑 提交于 2019-12-20 04:23:08
问题 How would you extract the data as follows: I want to extract from this arraylist: [{itemname=Original, number=12}, {itemname=BBQ, number=23}, {itemname=CatchUp, number=23}] This array: {"Original":12,"BBQ":23,"CatchUp":23} Thanks in advance! Here's the code used to generate the hashmap: ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); for (int i = 0; i<7;i++) { HashMap<String,String> map = new HashMap<String,String>(); map.put("itemname",chips[i]); map.put(

Most frequent n - words in java ArrayList

谁都会走 提交于 2019-12-20 04:21:15
问题 I need to find the most frequent words (n words, so if n = 5, the most frequent 5 words) in an ArrayList. private ArrayList<String> wordList = new ArrayList<String>(); public ArrayList<String> mostOften(int k) { ArrayList<String> lista = new ArrayList<String>(); Set<String> unique = new HashSet<String>(wordList); for (String key : unique) System.out.println(key + ": " + Collections.frequency(wordList, key)); return lista; } The function needs to return a list of the most frequent words,

delete duplicates in java arraylist

こ雲淡風輕ζ 提交于 2019-12-20 04:19:47
问题 Thanks Marko. I rewrite the code. try to make it simple. this time it can really compile. but it can only delete duplicate items sit next to each other. for example, if i put in 1 2 3 3 4 4 5 1 -- the output is 1 2 3 4 5 1. it can't pick up the duplicate at the end. (BTW: new to this website, if make any display mess my apologies) here's the new code: import java.util.*; public class SetListDemo{ public static void main(String[] args){ SetListType newList = new SetListType(); Scanner keyboard

How do I read a data from a JSON file with high efficiency in Java with Jackson?

自作多情 提交于 2019-12-20 04:14:41
问题 I store all static data in the JSON file. This JSON file has up to 1000 rows. How to get the desired data without storing all rows as ArrayList ? My code, I'm using right now and I want to increase its efficiency. List<Colors> colorsList = new ObjectMapper().readValue(resource.getFile(), new TypeReference<Colors>() {}); for(int i=0; i<colorsList.size(); i++){ if(colorsList.get(i).getColor.equals("Blue")){ return colorsList.get(i).getCode(); } } Is it possible? My goal is to increase

issue to select checkbox in onViewCreated()

ぃ、小莉子 提交于 2019-12-20 04:13:18
问题 I need to select automatically all checkboxes when I launch my app in onViewCreated() . With this code: @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); lv = (ListView)getView().findViewById(R.id.listview); displayPlanetList(); for (int i=0;i<plAdapter.getCount();i++) { Planet p=plAdapter.getItem(i); //if(p.getId()==3) { //System.out.println("NOME PIANETA:" + p.getName()); p.setSelected(true); //} p

Iterate over python dictionary to retrieve only required rows

大憨熊 提交于 2019-12-20 04:10:02
问题 I am getting the data in HTML table format from external source - from xml.etree import ElementTree as ET s = """<table> <tr><th>Release</th><th>REFDB</th><th>URL</th></tr> <tr><td>3.7.3</td><td>12345</td><td>http://google.com</td></tr> <tr><td>3.7.4</td><td>456789</td><td>http://foo.com</td></tr> </table> """ For converting html table to dictionary table = ET.XML(s) rows = iter(table) headers = [col.text for col in next(rows)] for row in rows: values = [col.text for col in row] out = dict

When clicked on grid view how to send arralist(position) to another actvity

人走茶凉 提交于 2019-12-20 03:24:06
问题 In this method I am receiving the ArrayList OkHttpHandler handler = new OkHttpHandler(MainActivity.this,new OkHttpHandler.MyInterface() { @Override public void myMethod(ArrayList result) { Toast.makeText(MainActivity.this, "Connection Succesful", Toast.LENGTH_LONG).show(); GridViewAdapter adapter = new GridViewAdapter(getApplicationContext(), R.layout.grid_item_layout, result); what I want is to send this arraylist to another activity in the gridiview. When the user clicks on the image in

When clicked on grid view how to send arralist(position) to another actvity

≡放荡痞女 提交于 2019-12-20 03:24:04
问题 In this method I am receiving the ArrayList OkHttpHandler handler = new OkHttpHandler(MainActivity.this,new OkHttpHandler.MyInterface() { @Override public void myMethod(ArrayList result) { Toast.makeText(MainActivity.this, "Connection Succesful", Toast.LENGTH_LONG).show(); GridViewAdapter adapter = new GridViewAdapter(getApplicationContext(), R.layout.grid_item_layout, result); what I want is to send this arraylist to another activity in the gridiview. When the user clicks on the image in