Classes in .net like List and Dictionary can be indexed directly, without mentioning a member, like this:
Dim MyList as New List (of integer)
...
MyList(5) 'get the sixth element
MyList.Items(5) 'same thing
How do I make a class that can be indexed like that?
Dim c as New MyClass
...
c(5) 'get the sixth whatever from c
...
Really like that function.
$matches = array('12', 'watt');
list($value, $unit) = $matches;
Is there a Javascript equivalent of that?
...
For example,
bitmask({1, 2, 3, 4}, {2, 4})
returns
{False, True, False, True}
The naive way to do this is to map a membership function over the list:
map(lambda(x, member(x, subset)), list)
but that's O(n*m) and it can be done in O(n+m).
What's the best way to implement bitmask() in your favorite language?
PS: It doesn't actua...
If I create a bunch of elements in a boost::ptr_list container how can I remove individual pointers from it? Say I do this:
boost::ptr_list intlist;
int *i = new int(3);
intlist.Add(i);
int *i2 = new int(1);
intlist.Add(i2);
int *i3 = new int(6);
intlist.Add(i3);
How can I remove say i3 and not i or i2 from the list?
...
Here's the problem
I'm trying to cast form List to an object MyTypes which is defined as
public class MyTypes : List<MyType> { ... }
It won't cast directly with (MyTypes) - compiler error
Or with as MyTypes - returns null
I would think this would be possible, but clearly I have to overload some casting operation.
Help!
...
Ok this is hard to explain, but here goes.
I have a 3D list of objects. The objects type are called CObject, another class CTile inherts CObject.
static public List<List <List <CObject>>> CObjList
= new List<List<List<CObject>>>();
Ok now lets say that the list is full of information in the correct way. (Can...
python:
m=[[0]*3]*2
for i in range(3):
m[0][i]=1
print m
I expect that this code should print
[[1, 1, 1], [0, 0, 0]]
but it prints
[[1, 1, 1], [1, 1, 1]]
...
Is there something like a two sided list in Java? Maybe a third party implementation?
Here a little example to demonstrate what I have in mind.
Original state:
A: 0-1-2-3
| | | |
B: 0-1-2-3
After removal of element 1 in B:
Null
|
A: 0-1-2-3
| / /
B: 0-1-2
The data structure must be accessible from both sides. So...
The function works well.
If add dynamical value located to other class, and i still want to declare the list0 at Main(). How to ?
Thank you.
using System;
using System.Collections.Generic;
using System.Text;
class Program
{
public static void Main()
{
List<string> list0 = new List<string>();
list0.Add("A");...
So I'm reading http://learnyouahaskell.com/starting-out as it explains lists, and using ghci on Vista 64. It says that [2,4..20] steps by 2 from 4 to 20. This works. It says [20,19..1] goes from 20 to 1, but doesn't explain. I take it that the first number is NOT the step, the step is the difference between the 1st and 2nd number. This i...
I'm writing a text editor using C#, I know i'm just reinventing the wheel but it's a learning experience and something I want to do.
Right now I have a basic Text Document using something that resembles a Gap Buffer however I have to update my line buffer to hold the start of each line each time an edit is made to the buffer.
I am look...
I have a problem using sIFR for links in a list.
When I try to apply it to the my links are perfectly skinned (with the right font and right color) but the last word of each link is cut or display on an other line.
When I apply it to the the text is well displayed but appears as a hypertextlink (blue and underline).
I have tryed an...
I have android application with ListView, where each row has own "refresh" button. Refreshing content is based on asynchronous http call, so until it completes (or timeout) I'd like to display some kind of graphical "busy" marker in each affected (clicked) row. What is best practice to do it? I see animated gifs - i.e. ones with rotating...
hi
How can I vertically align items in an unordered list to work also in IE6,7?
I can't just set line-height to the full height because I have both 1 row items and 2 rows items
My html code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></...
I'm developing a ebook manager on Lazarus, but I'm having some troubles with a component that I've never used(TListBox). On the TListBox named CategoryList, I have these items:
Literature and Fiction
Romance
Computers and Internet
Poetry
Professional and Technical
Science Fiction and Fantasy
Biographies and Memoirs
Busi...
Hi All,
How to convert a vector to a list?
...
So, according the W3C spec, the 'start' attribute in an ordered list is deprecated.
If you want to continue a list that's been broken up by a series of heading, you might have:
<ol start="15">
But that would not be allowed. The questions is how else could you/would you do it other than that which works in current browsers? Mission i...
"I have a List of objects with a property "CustomizationName".
I want to join by a comma the values of that property, i.e.; something like this:
List<MyClass> myclasslist = new List<MyClass>();
myclasslist.Add(new MyClass { CustomizationName = "foo"; });
myclasslist.Add(new MyClass { CustomizationName = "bar"; });
string foo = myclassl...
This sadly doesn't work:
long[] longs = new long[]{1L};
ArrayList<Long> longArray = new ArrayList<Long>(longs);
Is there a nicer way except adding them manually?
...