collections

Publishing/subscribing multiple subsets of the same server collection

拜拜、爱过 提交于 2019-12-17 08:47:44
问题 EDIT: this question, some of the answers, and some of the comments, contain a lot of misinformation. See how Meteor collections, publications and subscriptions work for an accurate understanding of publishing and subscribing to multiple subsets of the same server collection. How does one go about publishing different subsets (or "views") of a single collection on the server as multiple collections on the client? Here is some pseudo-code to help illustrate my question: items collection on the

Why is my Entity Framework Code First proxy collection null and why can't I set it?

蹲街弑〆低调 提交于 2019-12-17 08:32:51
问题 I am using DBContext and have two classes whose properties are all virtual. I can see in the debugger that I am getting a proxy object when I query the context. However, a collection property is still null when I try to add to it. I thought that the proxy would ensure that collection is initialized. Because my Poco object can be used outside of its data context, I added a check for the collection being null in the constructor and create it if necessary: public class DanceStyle { public

Why is my Entity Framework Code First proxy collection null and why can't I set it?

♀尐吖头ヾ 提交于 2019-12-17 08:32:23
问题 I am using DBContext and have two classes whose properties are all virtual. I can see in the debugger that I am getting a proxy object when I query the context. However, a collection property is still null when I try to add to it. I thought that the proxy would ensure that collection is initialized. Because my Poco object can be used outside of its data context, I added a check for the collection being null in the constructor and create it if necessary: public class DanceStyle { public

How to flatten all items from a nested Java Collection into a single List?

被刻印的时光 ゝ 提交于 2019-12-17 07:48:08
问题 Given a complex nested collection of objects such as: Set<List<Map<String, List<Object>>>> complexNestedCollection; Does a generic method exist to flatten this out and get a single List of all Object s contained within? A few details: The list shouldn't include collection objects themselves or map keys - only the values at the lowest level. It should follow the same ordering where possible - so in the example, items in the list would be in order, whereas ordering of maps/sets would depend on

How to flatten all items from a nested Java Collection into a single List?

人盡茶涼 提交于 2019-12-17 07:48:02
问题 Given a complex nested collection of objects such as: Set<List<Map<String, List<Object>>>> complexNestedCollection; Does a generic method exist to flatten this out and get a single List of all Object s contained within? A few details: The list shouldn't include collection objects themselves or map keys - only the values at the lowest level. It should follow the same ordering where possible - so in the example, items in the list would be in order, whereas ordering of maps/sets would depend on

Getting list of currently active managed threads in .NET?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 07:25:19
问题 For a "log information for support" type of function I'd like to enumerate and dump active thread information. I'm well aware of the fact that race conditions can make this information semi-inaccurate, but I'd like to try to get the best possible result, even if it isn't 100% accurate. I looked at Process.Threads, but it returns ProcessThread objects, I'd like to have a collection of Thread objects, so that I can log their name, and whether they're background threads or not. Is there such a

Initial capacity of collection types, e.g. Dictionary, List

拟墨画扇 提交于 2019-12-17 07:23:57
问题 Certain collection types in .Net have an optional "Initial Capacity" constructor parameter. For example: Dictionary<string, string> something = new Dictionary<string,string>(20); List<string> anything = new List<string>(50); I can't seem to find what the default initial capacity is for these objects on MSDN. If I know I will only be storing 12 or so items in a dictionary, doesn't it make sense to set the initial capacity to something like 20? My reasoning is, assuming that the capacity grows

Sort List of Strings with Localization

99封情书 提交于 2019-12-17 07:23:47
问题 I want to sort below List of strings as per user locale List<String> words = Arrays.asList( "Äbc", "äbc", "Àbc", "àbc", "Abc", "abc", "ABC" ); For different user locale sort output should be different as per there locale. How to sort above list as per user locale ? I tried Collections.sort(words , String.CASE_INSENSITIVE_ORDER); But this is not working for localization, so how to pass locale parameter to Collections.sort() or is there any other efficient way ? 回答1: You can use a sort with a

How do you query object collections in Java (Criteria/SQL-like)?

主宰稳场 提交于 2019-12-17 07:23:22
问题 Suppose you have a collection of a few hundred in-memory objects and you need to query this List to return objects matching some SQL or Criteria like query. For example, you might have a List of Car objects and you want to return all cars made during the 1960s, with a license plate that starts with AZ, ordered by the name of the car model. I know about JoSQL, has anyone used this, or have any experience with other/homegrown solutions? 回答1: I have used Apache Commons JXPath in a production

How do you query object collections in Java (Criteria/SQL-like)?

泪湿孤枕 提交于 2019-12-17 07:23:03
问题 Suppose you have a collection of a few hundred in-memory objects and you need to query this List to return objects matching some SQL or Criteria like query. For example, you might have a List of Car objects and you want to return all cars made during the 1960s, with a license plate that starts with AZ, ordered by the name of the car model. I know about JoSQL, has anyone used this, or have any experience with other/homegrown solutions? 回答1: I have used Apache Commons JXPath in a production