I have a "pointer" which keeps incrementing and I need to return the "head" of the pointer finally. I am in a dilemma to use either "pointer[0]" or have another variable called "head" and initialize it and return at the end. The former I feel makes the code looks soiled and later costs little memory. Any clean suggestion?
...
Possible Duplicate:
Clearest way to combine two lists into a map (Java)?
Given this:
List<Integer> integers = new ArrayList<Integer>();
List<String> strings = new ArrayList<String>();
strings.add("One");
strings.add("Two");
strings.add("Three");
integers.add(new Integer(1));
integers.add(new Inte...
Greetings,
I am writing a short simple script, but has became too crowded. Stuff has to do quite a few things
class Stuff
attr_accessor :config # stores configuration
attr_accessor :dbh # stores database handle
attr_accessor :logger # general logger to use
def command_do_job_1
end
def command_do_job_2
end
def com...
I have a data of Element class. I'm trying to write its values to a file but I'm having trouble:
< Some process to acquire values into the variable "fieldData" >
// Prepare file output
FileWriter fstream = new FileWriter("C:/output.txt");
BufferedWriter out = new BufferedWriter(fstream);
Element field = fieldData.getElement(i);
out.w...
Possible Duplicates:
which data structure is appropriate to query all points within distance d from point p
Storing objects for locating by x,y coordinates
I have a list of items, each with a location in 2D space (specified using euclidean geometry, i.e. as an (x, y) coordinate pair).
How should I store this list (e.g. hash...
I have a web page with 2 listboxes (HTML select control).
The first listbox is multi-select and contains a huge number of elements.
When I select one or more elements in the first listbox the content of the second listbox has to change based on the selected values. These values have to be taken form the database. Because the selection h...
I need to implement a mechanism which has a datastruture (Queue at this moment) that contains a list of pending request objects which are marked by different threads when being used and taken off when a thread is finished using it.
This datastructure could have up to a few thousand items in it at any given time and N threads will be t...
I need a data structure that can insert elements and sort itself as quickly as possible. I will be inserting a lot more than sorting. Deleting is not much of a concern and nethier is space. My specific implementation will additionally store nodes in an array, so lookup will be O(1), i.e. you don't have to worry about it.
...
I'm trying to code a small F# linear algebra library (for applications with small matrices, so memory isn't an issue), and I was wondering which data structure had the best performance characteristics, in terms of element lookup times, since I'll need that to define matrix operations?
...
Simple and common tree like data structures
Data Structure example
Animated Cartoons have 4 extremities (arm, leg,limb..)
Human have 4 ext.
Insects have 6 ext.
Arachnids have 6 ext.
Animated Cartoons have 4 by extremity
Human have 5 by ext.
Insects have 1 by ext.
Arachnids have 1 by ext.
Some Kind of Implementation
Level/Table0
...
hi,
I am trying to implement LRU Cache using C++ . I would like to know what is the best design for implementing them. I know LRU should provide find(), add an element and remove an element. The remove should remove the LRU element. what is the best ADTs to implement this
For ex: If I use a map with element as value and time counter as ...
Hi - been writing some data structures of late as a review for myself. I was wondering if anyone had some feedback on the code below, better, faster ways perhaps?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MaxHeapPriorityQueue
{
...
Please critique my code. I noticed my last assert fails with value 277. I expected the value to 255 (1/2 500+10). Is this a valid test or have I done something wrong?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RedBlackTree
{
pu...
HashMap savedStuff = new HashMap();
savedStuff.put("symbol", this.symbol); //this is a string
savedStuff.put("index", this.index); //this is an int
gives me the warning:
HashMap is a raw type. References to generic type HashMap<K,V> should be parameterized
...
HashMap myMap = (HashMap) getLastNonConfigurationInstance();
myMap is always null. getLastNonConfigurationInstance() returns an object. My map has two keys "symbol" and "name".
public Object onRetainNonConfigurationInstance()
{
HashMap myMap = new HashMap();
myMap.put("symbol", this.symbol);
final Object da...
Hi,
I am having this problem with word boundary identification. I removed all the markup of the wikipedia document, now I want to get a list of entities.(meaningful terms). I am planning to take bi-grams, tri-grams of the document and check if it exists in dictionary(wordnet). Is there a better way to achieve this.
Below is the sample ...
Each time a function is called, if it's result for a given set of argument values is not yet memoized I'd like to put the result into an in-memory table. One column is meant to store a result, others to store arguments values.
How do I best implement this? Arguments are of diverse types, including some enums.
In C# I'd generally use Da...
In an interview when I ask the recent graduate students that what is the difference between array and linked list, the first answer normally is "In array you have same data types and in the linked list you can have different data types." When I told them to explain they will say that they have just read it somewhere or that they don't kn...
I have the following C# code fragment:
using System;
class count {
public static void Main()
{
int [] a = {-30, 30, -20, -10, 40, 0, 10, 5};
int i,j,k;
int N=8;
for (i=0; i < N; ++i)
for (j=i+1; j < N; ++j)
for (k=j+1; k < N; ++k)
if (a[i] + a[j] + a[k] == 30)
Console.WriteLine (a[i].ToString () + a[j].ToSt...
I'm currently experimenting with rendering a Mandelbrot set and I've quickly come to realize that it would be useful to not have to recalculate the maximum iteration count for each rendering...on the other hand it's a lot of data to keep track of. It seems to me (based on my limited experience with RDMSes) that a relational database is p...