I have a scenario where I have a list of classes, and I want to mix up the order. For example:
private List<Question> myQuestions = new List<Question>();
So, given that this is now populated with a set of data, I want to mix up the order. My first thought was to create a collection of integers numbered from 1 to myQuestions.Count, a...
I understand that any Collection (here I am talking about regular non-generic) should have implemented ICollection, IEnumerable and IList incase of regular object collection or IDictionary in case of Dictionaries.
[Still, the question I ask is not specific to collections]
IList is derived from ICollection and IEnumerable
ICollection i...
Basically i want to merge two Iqueryable to one Iqueryable and then return the complete record set after my loop ends. It runs perfectly but in the end my objret have nothing but when i debug the loop obj have some records. wht im doing wrong
IQueryable<MediaType> objret = Enumerable.Empty<MediaType>().AsQueryable();
var typ = _db.Media...
Hi,
For a php project I use a Collection class to handle my objects and lazyloading in Java-like collections.
Now my object has a collection of emailaddresses for example. So I call the getEmailAddresses() function of the object which calls the mapper to return a collection of emailaddresses.
This works fine, but when I do a foreach l...
Hi,
I am looking for sample code which explains Guava ForwardingList class. Basically I am implementing a custom ArrayList class which will be used to solve this requirement mentioned in my earlier SO question. I never used Google collection before. But by just looking at the JavaDoc of ForwardingList, I think I can implement my custom ...
A memory intensive program that I wrote ran out of memory: threw an OutOfMemory exception. During attempts to reduce memory usage, I started calling GC.GetTotalMemory(true) (to write the total memory usage to debug file), which triggers a garbage collect.
For some reason, when calling this function I don't get an out of memory exceptio...
I'm currently reviewing the security implications of various warnings in a large Java EE application. Since most of the code is several years old, it contains many uses of the raw collection types:
List items = new List();
rather than the parametrized collection types:
List<Item> items = new List<Item>();
The only security implicat...
I need an efficient data structure to store a list of integers. The amount in the list could range from 1 to probably never more than 1000. The list will be queried about 20 times per request. What would be the most efficient collection type to store these in?
UPDATE
To give a little more insight, we'll take www.wikipediamaze.com (a li...
In GAE-python, you can model a one-to-many relationship by assigning a reference property to the child model.
class Book(db.Model):
title = db.StringProperty()
class Author(db.Model):
book = db.ReferenceProperty(Book, collection_name = 'authors')
is_primary = db.BooleanProperty()
name = db.StringProperty()
This way, I can ...
I have a datagridView, that is bound to a List. This List is made up of my class which contains 2 public properties, a String Name, and another List CustomList. See below:
public class MyClass2
{
public string Name
{ get; set;}
public string Description
{
get;
set;
}
}
public class MyCla...
Hi,
Assume you need to store/retrieve items in a Collection, don't care about ordering, and duplicates are allowed, what type of Collection do you use?
By default, I've always used ArrayList, but I remember reading/hearing somewhere that a Queue implementation may be a better choice. A List allows items to be added/retrieved/removed at...
I'm new to java and just getting into querying databases. so far I have my results in a ResultSetMetaData. I'm think that for each row in the dataset I should add it to some form of collection? Can anyone tell me the best practice for this?
thanks,
Jonesy
...
recently, I research for the collection framework, and find LinkedSet(AS3Commons collection framework,it is a good opensource framework) written in ActionScript, but it can't use as dataProvider in ComboBox or DataGrid, because only implements ICollectionView can use as dataProvider. So I want to try if a class implements ICollectionVie...
Is there a standard representation for typed java collections in UML2? I am working on a class diagram and would like to avoid Java syntax, when using something like Map as type for a class attribute.
- foo : Map<Integer, String>
...
After searching on the web I didn't found a well-done article on the JCF and what
there was prior of the framework.
Does anyone know a book, site or itself a good history paper on the question title?
...
I'm getting tired of using code like this:
var count = 0;
if (myEnumerable != null)
{
count = myEnumerable.Count();
}
And this is a bit pedantic:
var count = (myEnumerable ?? new string[0]).Count();
Is there any tidier way of doing this? I once had a (badly named) PhantomCount extension method on IEnumerable<> that used my fir...
If I wanted to make a custom implementation of a Queue is correct to
say that I can choose whatever order I want (not FIFO) but I must always
respect the fact that the element to remove is that positioned as "head"?
but for insertion operation I'm not obliged to put the element to the tail (like into FIFO)?
...
Hi
I use Castle.ActiveRecord's HasMany mapping.
I have something like:
[HasMany (typeof (childtype), ColumnKey = "this_relation_column", Table = "childtype_table")]
I would like to use a different column on childtype_table to relate with this_relation_column.
Actually, this_relation_column is of type text (string), and the PK of child...
Hi All,
I have a set of classes (MyClass1, MyClass2, MyClass3) that implement an interface (IMyClass).
I am interested in creating a method to fill and return a list (Collection.Generics.Lists<>) of objects that have common interface MyClassX (List<IMyClass>). But how?
Each class has a constructor MyClassX which does something differe...
So I am looking at a heap with jmap on a remote box and I want to force garbage collection on it. How do you do this without popping into jvisualvm or jconsole and friends?
I know you shouldn't be in the practice of forcing garbage collection -- you should just figure out why the heap is big/growing.
I also realize the System.GC() does...