Hi,
I am trying to find out what would be the best way to bind first element of ISet (Iesi.Collection) as a first element.
So basically I only have to use some kind of collection that has an indexer (and ISet doesn't) then I can write code like this (which works perfectly well):
<%: Html.EditorFor(x => x.Company.PrimaryUsers[0].Email)...
Certain collection types in .Net have an optional "Initial Capacity" constructor parameter. i.e.
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 storin...
I have a collection of objects that's constantly changing, and I want to display some information about the contents every so often (my application is multi-threaded, and differently threads are constantly submitting requests to modify an object in the collection, so it's unpredictable).
If I lock the collection, I can iterate over it a...
If I enter the code below, I get an error. Basically, the foreach will break when it comes across a Control that isn't a label.
foreach (Label currControl in this.Controls()) {
...
}
I have to do something like this.
foreach (Control currControl in this.Controls()) {
if(typeof(Label).Equals(currControl.GetType())){
...
...
I have a private LinkedList in a Java class & will frequently need to retrieve the last element in the list. The lists need to scale, so I'm trying to decide whether I need to keep a reference to the last element when I make changes (to achieve O(1)) or if the LinkedList class does that already with the getLast() call.
What is the big-...
Judging from the result of my last inquiry, I need to calculate and preset the widths of a set of columns in a table that is being made into an Excel file. Unfortunately, the string data is stored in a row-based format, but the widths must be calculated in a column-based format. The data for the spreadsheets are generated from the follow...
I need to cast an IList to a Collection (System.Collections.ObjectModel)
How do you go about this?
...
I have a collection of objects and I know that I can sort by NAME (string type) by saying
collEquipment.Sort((x, y) => string.Compare(x.ItemName, y.ItemName));
that WORKS.
But I want to sort by a ID (integer type) and there is no such thing as Int32.Compare
So how do I do this? This doesn't work
collEquipment.Sort((x, y) => (x.ID ...
Hi,
the answer to this question is probably "not possible", but let me ask regardless :)
Assuming we have a very simple JAVA class that has a primary key, for example:
class Person {
String ssid;
String name;
String address;
...
}
Now, I want to store people in a collection, meaning I will have to override the equals...
Hi
I'm using arraylist in java and I need to add integers during 10 iterations (integer is got randomly from an array of integers named arrint) without any repetition:
for (int i =0; i<10; ++i)
array.add(integer);
and then add in the same array 20 other integers for the same array of integer(arrint) during 20 iteration without re...
I got several entities. Two of them got a many-to-many relation. When I do a bigger operation on these entities it fails with this exception:
org.hibernate.exception.ConstraintViolationException: could not insert collection rows:
I execute the operation i a @Transactional context. I don't do any explicit flushing i my daos. The flush ...
Hi everyone,
Basically I have been programing for a little while and after finishing my last project can fully understand how much easier it would have been if I'd have done TDD. I guess I'm still not doing it strictly as I am still writing code then writing a test for it, I don't quite get how the test becomes before the code if you do...
I have an Iterator that I use on a HashMap, and I save and load the iterator.
is there a way to get the previous key in the HashMap with Iterator? (java.util.Iterator)
Update
I save it as an attribute in a Red5 connection and then load it back to continue working where i stopped.
Another update
I'm iterating through the keyset of the...
Apart from the fact that hashSet does not allow duplicate values, what is the difference between a HashMap and Hashset...?
I mean implementaion wise.....? It's a little bit vague because both use hash table to store values.....
...
A colleague mentioned that he heard about a lightweight collection which would automatically page out to disk when it's contents got too full - but he couldn't remember the name. I would imagine it looks something like this:
PagingCollection<Serializable> pagingCollection = new PagingArrayList<>();
pagingCollection.setMaxSizeInMemory(50...
I have a toString() representation of an ArrayList.
Copying the toString() value to clipboard, I want to copy it back into my IDE editor, and create the ArrayList instance in one line. In fact, what I'm really doing is this:
my ArrayList.toString() has data I need to setup a unit test.
I want to copy this ArrayList.toString() into my...
Is there anything in Java that implements something like the following
interface MSet<T> extends Iterable<T> {
/**
* return a new set which consists of this set plus a new element.
* This set is not changed.
*/
MSet<T> add(T t);
/**
* return a new set which consists of this set minus a designated element...
After trying to develop our own control to display a table of data we stumbled on the WPF toolkit DataGrid and thought we were saved. A couple hours later I'm scratching my head trying to figure out if it can do what we really want it to do. The DataGrid seems to be based on displaying various properties of a single object, where I thi...
hello ,
how do you pass in a collection to an MVC 2 partial view?
I saw an example where they used the syntax;
<% Html.RenderPartial("QuestionPartial", question); %>
this passes in only ONE question object..
what if i want to pass in several questions into the partial view and , say, i want to list them out...how would i pass in SE...
Hi everyone,
Writing test cases for my project, one test I need is to test deletion. This may not exactly be the right way to go about it, but I've stumbled upon something which isn't making sense to me.
Code is like this:
[Test]
private void DeleteFruit()
{
BuildTestData();
var f1 = new Fruit("Banana",1,1.5);
var f2 = new...