collections

Form Collection error bubbling

南楼画角 提交于 2020-01-02 08:18:00
问题 Hello I have a problem with collection of text fields in my form. When there are errors in one of the fields, these errors bubbles into parent form so they are not assigned to field but to parent itself. It is the 'points' collection in the following piece of code. I tried to set error_bubbling to false, but it has no effect. <?php namespace JamaLvova\AdminBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component

StringCollection in application settings doesn't get stored

家住魔仙堡 提交于 2020-01-02 07:09:11
问题 I would like to use a StringCollection as application settings, however while reading it's not a problem, I found out that settings are not stored. How to make it works? Any workaround? What's the problem here? Code I'm using: private static void AddToRecentProfiles(string path) { if (SpellCaster3.Properties.Settings.Default.RecentProfiles == null) SpellCaster3.Properties.Settings.Default.RecentProfiles = new StringCollection(); int index = SpellCaster3.Properties.Settings.Default

Count occurrences of each item in a Scala parallel collection

馋奶兔 提交于 2020-01-02 06:53:30
问题 My question is very similar to Count occurrences of each element in a List[List[T]] in Scala, except that I would like to have an efficient solution involving parallel collections. Specifically, I have a large (~10^7) vector vec of short (~10) lists of Ints, and I would like to get for each Int x the number of times x occurs, for example as a Map[Int,Int] . The number of distinct integers is of the order 10^6. Since the machine this needs to be done on has a fair amount of memory (150GB) and

Java: select from collection only elements of provided type

北城以北 提交于 2020-01-02 06:48:15
问题 I have a collection of elements of type B and C, which all extends A. I need to filter the collection to get elements of only B type. Is there any way to do it except: for (A a : initCollection) { if (a instanceof B) { newCollection.add(a)? } } Thanks 回答1: Guava was alluded to in other answers, but not the specific solution, which is even simpler than people realize: Iterable<B> onlyBs = Iterables.filter(initCollection, B.class); It's simple and clean, does the right thing, only creates a

java multi mapping arraylist

我只是一个虾纸丫 提交于 2020-01-02 04:47:05
问题 Is it possible to map key to Multi Dimensional Array List. Some thing like following example.. Map<K,V> Where K is key for list of alphabet and V is a multi dimensional array list or normal array list that stores list of word. Some thing like a application that reads a dictionary file. I want to see an example. Example can be anything related to Map and Multi Dimensional Array-list. Or is there any other efficient way to implement collection? I have never used such implementations so if there

How deep would you expect the immutability of an immutable list to be?

陌路散爱 提交于 2020-01-02 03:25:21
问题 If you have an immutable list, you expect it to always return a reference to the same object when you ask for, say list.get(0) My question is, would you expect to be able to mutate the object and have the mutation reflected next time you get it from the list? 回答1: It depends on the context. In a general purpose library, all we should assume is that the list is immutable. Changes to the elements in the list would be reflected to all callers, as a direct consequence of returning the same

How to map nested collections using MapStruct?

蓝咒 提交于 2020-01-02 03:00:54
问题 I have 2 entities: Entity 1: public class Master { private int id; private Set<SubMaster> subMasters= new HashSet<SubMaster>(0); } public class SubMaster{ private int subId; private String subName; } Entity 2: public class MasterDTO { private int id; private Set<SubMaster> subMasters= new HashSet<SubMaster>(0); } public class SubMasterDTO{ private int subId; private String subName; } I am using MapStruct Mapper to map values of POJO to another. public interface MasterMapper{ MasterDTO toDto

BlockingCollection or Queue<T> for jobs?

心已入冬 提交于 2020-01-02 01:30:11
问题 I am developing a windows forms application ( c# ), and while program is running, it creates objects adds them to a list. I have to process the items in the list , with FIFO ( first in first out ). I want to do this in a backgroundthread and i have to process them in order, number 1 , number 2, number 3 and so on. And as soon as an item gets added to the list i want to process it. So i have to have something to check that list. What is the best way to achieve this? I know that

How to reverse the sort of a Groovy collection?

偶尔善良 提交于 2020-01-02 01:20:11
问题 I am sorting a list based on multiple fields. sortedList.sort {[it.getAuthor(), it.getDate()]} This works fine, but I want the date to be reversed and reverse() does not work. How do I sort the author in ascending order but sort the date in descending (reverse) order? Example of what I want: Author Date Adam 12/29/2011 Adam 12/20/2011 Adam 10/10/2011 Ben 11/14/2011 Curt 10/17/2010 Example of what I have: Author Date Adam 10/10/2011 Adam 12/20/2011 Adam 12/29/2011 Ben 11/14/2011 Curt 10/17

VBA - How to add a collection to a collection of collections

会有一股神秘感。 提交于 2020-01-02 01:17:12
问题 I am trying to create code to represent a form document using VBA in Word 2007. I have created classes to represent Section, QuestionSet and Question. So I have 15 Sections. I have created a function to create each 'Section' Object add it to the 'Sections' Collection then destroy the object, the result being that the objects remain persistent in the collection (or something). Is it possible to use the same method to add collections to collections or would I have to define each collection