Perhaps I am barking up the wrong tree (again) but if it is normal practice to have a property typed as a scala.collection.immutable.Set[A], then how would you create one of these given a scala.Iterable[A]? For example:
class ScalaClass {
private var s: scala.collection.immutable.Set[String]
def init(): Unit = {
val i =...
I have asked quite a few questions about the Scala collection types and how they might actually be used. Consider how I might write some service API/implementation in Java:
public interface JavaProductAPI {
public Set<IProduct> getProducts(String isin);
}
And now the impl:
public class JavaProductAPIImpl implements JavaProductAP...
I have just found out this syntax for a scala Map (used here in mutable form)
val m = scala.collection.mutable.Map[String, Int]()
m("Hello") = 5
println(m) //PRINTS Map(Hello -> 5)
Now I'm not sure whether this is syntactic sugar built in to the language, or whether something more fundamental is going on here involving the fact that a...
I need to sort a List based on the difference between the strings in the list and a target string.
What's the best way of implementing this kind of sorting algorithm?
I don't care too much about performance but the collection could potentially become big (let's say half a million tops).
Any Help Appreciated!
...
What's the best way in C++ to copy a pair from a map to vector? I'm doing this so I can subsequently sort the vector.
...
I'm trying to hold a list of items in a collection with a key of my choice. In Java, I would simply use Map as follows:
class Test {
Map<Integer,String> entities;
public String getEntity(Integer code) {
return this.entities.get(code);
}
}
Is there an equivalent way of doing this in C#?
System.Collections.Generic.Hashset doe...
I am trying to declare List in PowerShell, where the Person is defined using Add-Type:
add-type -Language CSharpVersion3 -TypeDefinition @"
public class Person
{
public Person() {}
public string First { get; set; }
public string Last { get; set; }
}
"@
This works fine:
New-Object Person
New-Object...
I have an ArrayList and I want to copy it exactly. I use util classes when possible ont the assumption that someone spent some time making it correct. So naturally I end up with the Collections class which contains a copy method.
ss I hav the following::
List<String> a = new ArrayList<String>();
a.add("a");
a.add("b");
a.add("c");
Lis...
I may have designed myself into a corner with this problem but I feel like there's a workable known solution to something like this that I'm not seeing. It may well be that I'm completely overcomplicating the problem and skipped over the obvious solution. Any advice would be greatly appreciated.
I have a set of entities defined as inter...
I'm looking for a collection just like Dictionary(OF Key, Value) but I don't actually need a key and value. Key itself is enough. So something like Collection(Key). It shouldn't accept duplicate keys.
I've looked up couple of collections in .NET Framework but couldn't find what I want. Currently I'm abusing Dictionary(OF String, String)...
Are .NET collections with large number of items apt to be stored in the LOH?
I'm curious about List and Dictionary specifically. In my code, I store a large number (40k+) of relatively small objects (lets say 1k) in temporary Lists and Dictionarys for processing. Does the number of items in these collections increase the likelihood of b...
Lat week I downloaded the Glazed List library into eclipse. I have been looking through the tutorials and it seems that everything is designed to run jTable or SWT. I am need a backing list(Map, table, whatever) for simple HTML tables that can be sortable. I have been doing this by rolling my own classes to create HTML tables from either...
I have a custom collection type of data. This data is sorted by three properties in their order, e.g. take the following example:
class Data
{
public int PropertyA() { get; set; }
public int PropertyB() { get; set; }
public int PropertyC() { get; set; }
}
The collection must maintain the order of A, B, C, e.g.:
[A, B, C]
[1, 2,...
I am trying to convert a generic collection (List) to a DataTable. I found the following code to help me do this:
// Sorry about indentation
public class CollectionHelper
{
private CollectionHelper()
{
}
// this is the method I have been using
public static DataTable ConvertTo<T>(IList<T> list)
{
DataTable table = CreateTable<T>();...
I want to fill items in a combobox, each of them has different behaviour.
Yes I know I could simply create 3 classes deriving from a base class. But my question is kind of "is there another way" and "what is possible".
In Java one can do "new MyClass(){public void overriddenmethod(){...} }" but in C# we can not, can we?
Now I use a lamb...
In a .Net 3.5 (Windows) service, I would like to store a small collection of values in the config file. Basically, I need to allow admins to add and remove values from this small collection. What do I need to add to the config file to store a collection of small values, and how can I read the collection in C#?
To clarify, the collect...
Is there a quick way to convert a Generic Dictionary from one type to another
I have this
IDictionary<string, string> _commands;
and need to pass it to a function that takes a slightly different typed Dictionary
public void Handle(IDictionary<string, Object> _commands);
...
Hi, I've a List<String> object that contains country names. How can I sort this list alphabetically?
Thanks.
...
I need a collection that can lookup a value based on the key and vice versa. For every value there is one key and for every key there is one value. Is there a ready to use data structure out there to do this?
Thanks in advance.
...
This used to work for me and then it failed. I want to return only those items that contain all the filters, not at least one filter as it is doing now. WHat is wrong here?
private IQueryable<IndexItem> FilteredIndex (IQueryable<IndexItem> index, IEnumerable<string> filters)
{
var filteredIndex= from f in filters.AsQueryab...