HashMapList keeps its elements inside a HashMap) and when I call add method this error message will be shown in the concole "Exception in thread "main" java.lang.NullPointerException
public class HashMapList<K, V extends Product> extends AbstractList<Product> {
public V element;
public int index;
Map<Integer, V> map;
public HashMapLi...
in which situations we have to implement the Comparable interface?
...
I'm trying to use a JDO with Google App Engine and Scala. The api for the execute returns Object (but it's really a java collection) and I want to get it into a scala list to iterate over it.
My code looks like this so far:
val pm = PMF.factory.getPersistenceManager
val query = "select from User "
val gamelist:List[User] = List(pm.ne...
this is my collection which I make:
Test<v> map = new Test<V>();
but when I call sort method which I override it in Test class and also map1 is one collection that I make it in the Test class which will keeps the elements that I add to the map collection,this exception will be thrown that it is for line 5:a[i] = map.get(new Integer(i)...
I have a CustomerRepository class (in my BL), and I am returning a collection as follows:
public static ICollection<Customer> FindCustomers()
{
Collection<Customer> customers = null;
try
{
customers = DAL.GetCustomers();
}
catch (Exception ex)
{
//l...
I have an two interfaces defined as follows:
public interface IFoo
{
...
}
Public interface IFooWrapper<T> where T : IFoo
{
T Foo {get;}
}
I want to be able to declare a collection of IFooWrappers but I don't want to specify the implementation of IFoo.
Ideally I want to do something like the:
IList<IFooWrapper<*>> myList;
I can...
I have used System.Collections.Queue and its object form_elements_queue
if (form_elements_queue.Count > 0)
queue_element = (RecordQueue)form_elements_queue.Peek();
I'm modifying the queue_element like below,
queue_element.Children--;
RecordQueue is my custom Type which I Enqueue in form_elements_queue.
but its not referenci...
Do you just base your STL container selections on the following attributes?
Searching/Updating
Insertion and
Deletion
If not, what else do you base your selections upon?
Is there any reference out there that lists how each container performs across all these different attributes?
...
When I want to make a value type read-only outside of my class I do this:
public class myClassInt
{
private int m_i;
public int i {
get { return m_i; }
}
public myClassInt(int i)
{
m_i = i;
}
}
What can I do to make a List<T> type readonly (so they can't add/remove elements to/from it) outside of my ...
I want to return all the entities of a database where ALL child elements of a parent are found in the control collection.
So, I thought something like this would work:
var toInclude = new List<int>{1, 2, 3};
var result = allObjs.Where(obj => obj.Children.All(child => toInclude.Contains(child)));
That doesn't work. It returns all ent...
I'm using .NET 2.0
I have a large array of string.
I want to check whether a particular string is there in the array or not,
I'm not sure, whether following code is optimized or I need to make it more optimized.
please guide.
string []test_arr= new string[]{"key1","key2","key3"};
Boolean testCondition = (new List<string>(test_arr)).Cont...
Tried to run Run Code Analysis on a project here, and got a number of warnings that said something like this:
CA1002 : Microsoft.Design : Change 'List<SomeType>' in 'SomeClass.SomeProtectedOrPublicProperty' to use Collection, ReadOnlyCollection or KeyedCollection
Why should I use Collection<T> instead of List<T>? When I look at the...
Hi.
Is there any way how to do
ICollectionView.Refresh()
or
CollectionViewSource.GetDefaultView(args.NewValue).Refresh();
in a separate thread?
I know I can use dispatcher, but this collection is binded to a ListView and it throws cross thread Exceptions.
The reason why I need a second thread is, that I have Control which dis...
I'm just beginning to explore the M-V-VM design pattern while redeveloping an application and I'm running across a consistent theme where I have collections that I need my ViewModel to expose to the View which contain items which are to be selected by the user. Please note that when I say "selected" what I mean is that they are chosen in...
Which approach is recommended in a DDD world... and why ?
aggregateRoot.Items.Add(...)
aggregateRoot.AddItem(...)
I think the first option is better since it is more related to the ubiquitous language.
Should I expose a readonly (IEnumerable) collection and some AddItem()/RemoveItem()/etc on the aggregateRoot (option 1) or expose a ...
What I need is a collection which allows multiple keys to access a single object.
I need to apply frequent alterations to this object.
It also must be efficient for 500k+ entries.
...
I have a method which summarizes a collection of decimal values using a method similar to this...
Dim _amountCollection as New List(Of Decimal)
_amountCollection.Add(145.12D)
_amountCollection.Add(11.32D)
_amountCollection.Add(6547.07D)
Dim _totalAmount as Decimal
For Each _individualAmount as Decimal in _amountCollection
_totalAmou...
Hi,
Suppose the following List
List<String> list = new ArrayList<String>();
list.add("s1");
list.add("s2");
list.add(null);
list.add("s3");
list.add(null);
list.add("s4");
I need a Helper class that removes null references. Something like
SomeHelper.removeNullReference(list);
Now, list only contains "s1", "s2", "s4", "s4". Non-nul...
Ok so here is my issue. I have to HashSet's, I use the Removeall method to delete values that exist in one set from the other.
Prior to calling the method, I obviously add the values to the Sets. I call .toUpperCase() on each String before adding because the values are of different cases in both lists. There is no rhyme or reason to th...
I have a collection of instances of class A.
At some point an instance of A realizes that it should delete itself. I want to inform the collection of this, but I do not want A to know anything about the collection.
What is the best way to go about this? It seems to me like A knowing about the collection is very bad coupling, but if I am...