|
George_George wrote: What means "algorithmic efficiency"
George, why to you keep asking us question for which there is already a perfectly acceptable and easily found[^] answer?
George_George wrote: What means .... "driving factor"?
That means every project has it's own factors related to optimization needs. They can be very different from project to project. For example the use model of a system typically provides an understanding of many of these factors.
led mike
|
|
|
|
|
Thanks led mike,
Sorry it is my bad English. Now it is clear now. Sorry I have another question about the 1st link,
"On questions such as these, there are two ways to find the answer. The first is to build the code and look at the generated IL (or the resulting assembly, remembering that you get debug code if you run in the debugger. Attach to a running process, and then you get the optimized native code), or to time the code with a stopwatch."
I think either in debug mode in Visual Studio or attach to a running process, we can only debug through either the source code or the native code, any ways to debug through IL code in debug/release mode?
regards,
George
|
|
|
|
|
hy everyone!
sorry for me asking again, but i am not sure how to do this:
i read from a file which is a outputtemplate (i have fields in there which have to be replaced by it's values).
then there are two line which describes the table e.g.
|tag1_01| |tag2_01| |tag3_01| |tag4_01| |tag5_01|
|tag6_01| |tag7_01| |tag8_01|
(the location of the tags and finally the values are important, because otherwise it won't appear to be a table
the _01 is used to help me replace the tags with it's values.
so lets say i do want to duplicate this line ten times to finally have 11 lines.
the replacement of the _01 to _02 etc. isn't the challange for me, but i wonder how to insert the new lines at the correct location. because as far as i know i am only able to insert it at an index position. well, in my case i would try to find the _01 entries by reading line after line in the file. when i find it i copy these two lines to a tempstringvariable. then loop for the desired number, replace _01 by _02 etc.
now the tricky part: i have to find out at which position the two lines end. well i guess this is indexof(tempstring) + tempstring.length + 2 (linefeed). and then insert the lines + linefeeds into there.
but isn't there an easier way like "insert line after this line"?
thanks for any further hint which help me realize this in a more easy way!
stephan.
|
|
|
|
|
I think you may have a knowledge representation issue here. You're representing the template with a single string, right? In that case, you've built a find-replace model where now you need an example-build model. Looks like you're going to either A) devise a very clever solution using your current system by changing the table template to a line template B) change your templating model to have better supporting code or C) get rid of the template system in favor of a custom formatter or custom StreamWriter.
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Also, almost forgot, You could look into constructing using XML... XSL...
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Hello all...
when i enter a text in any WindowsForms Textbox with forward slash "/" the textbox reverse the text and make it wrong
e.g. if i enter 990 first then / then 130 the system will display it 130/990 note 990/130...
how can i solve that?
Thanks in advanced...
Thanks
|
|
|
|
|
What are you binding the textbox to?
|
|
|
|
|
Atually I'm developing a documents In-System and this is the document no.
I face this problem when I convert the textbox order to be Right To Left
Thanks
modified on Thursday, May 1, 2008 8:12 AM
|
|
|
|
|
when i am trying to insert i the patient detail in the BINARY SEARCH TREE it give me the following error "The best overload method for IBSTree.Insert(System.Icomparable) has some invalid arguments".
<br />
using System;<br />
using System.Collections;<br />
<br />
<br />
<br />
public interface IPatient<br />
{<br />
string FirstName { get; set; }<br />
<br />
<br />
}<br />
<br />
<br />
using System;<br />
using System.Collections;<br />
<br />
<br />
<br />
public class Patient: IPatient<br />
{<br />
private string fname;<br />
<br />
public string FirstName<br />
{<br />
get<br />
{<br />
return fname;<br />
}<br />
set<br />
{<br />
fname = value;<br />
}<br />
}<br />
public int CompareTo(IPatient obj)<br />
{<br />
Patient p1 = (Patient)obj; <br />
return fname.CompareTo(p1.fname);<br />
} <br />
}<br />
<br />
using System;<br />
using System.Collections;<br />
<br />
public class BTreeNode<br />
{<br />
private IComparable item;
private BTreeNode lchild;
private BTreeNode rchild;
<br />
public BTreeNode(IComparable item)<br />
{<br />
this.item = item;<br />
lchild = null;<br />
rchild = null;<br />
}<br />
<br />
public IComparable Item<br />
{<br />
get { return item; }<br />
set { item = value; }<br />
}<br />
<br />
public BTreeNode LChild<br />
{<br />
get { return lchild; }<br />
set { lchild = value; }<br />
}<br />
<br />
public BTreeNode RChild<br />
{<br />
get { return rchild; }<br />
set { rchild = value; }<br />
}<br />
}<br />
<br />
<br />
public class BSTree : IBSTree<br />
{<br />
private BTreeNode root;<br />
public BSTree()<br />
{<br />
root = null;<br />
}<br />
<br />
public bool IsEmpty()<br />
{<br />
return root == null;<br />
}<br />
<br />
public bool Search(IComparable item)<br />
{<br />
return Search(item, root);<br />
}<br />
<br />
private bool Search(IComparable item, BTreeNode r)<br />
{<br />
if (r != null)<br />
{<br />
if (item.CompareTo(r.Item) == 0)<br />
return true;<br />
else<br />
if (item.CompareTo(r.Item) < 0)<br />
return Search(item, r.LChild);<br />
else<br />
return Search(item, r.RChild);<br />
}<br />
else<br />
return false;<br />
}<br />
<br />
<br />
public IComparable PartialSearch(IComparable item)<br />
{<br />
return PartialSearch(item, root);<br />
}<br />
<br />
private IComparable PartialSearch(IComparable item, BTreeNode r)<br />
{<br />
if (r != null)<br />
{<br />
if (item.CompareTo(r.Item) == 0)<br />
return r.Item;<br />
else<br />
if (item.CompareTo(r.Item) < 0)<br />
return PartialSearch(item, r.LChild);<br />
else<br />
return PartialSearch(item, r.RChild);<br />
}<br />
else<br />
return null;<br />
}<br />
<br />
<br />
public void Insert(IComparable item)<br />
{<br />
if (root == null)<br />
{<br />
root = new BTreeNode(item);<br />
<br />
}<br />
else<br />
Insert(item, root);<br />
}<br />
<br />
private void Insert(IComparable item, BTreeNode ptr)<br />
{<br />
if (item.CompareTo(ptr.Item) < 0)<br />
{<br />
if (ptr.LChild == null)<br />
{<br />
ptr.LChild = new BTreeNode(item);<br />
<br />
}<br />
else<br />
Insert(item, ptr.LChild);<br />
}<br />
else<br />
{<br />
if (ptr.RChild == null)<br />
{<br />
ptr.RChild = new BTreeNode(item);<br />
<br />
}<br />
else<br />
Insert(item, ptr.RChild);<br />
}<br />
}<br />
<br />
public void Delete(IComparable item)<br />
{<br />
BTreeNode ptr = root;
BTreeNode parent = null;
while ((ptr != null) && (item.CompareTo(ptr.Item) != 0))<br />
{<br />
parent = ptr;<br />
if (item.CompareTo(ptr.Item) < 0)
ptr = ptr.LChild;<br />
else<br />
ptr = ptr.RChild;<br />
}<br />
<br />
if (ptr != null)
{<br />
if ((ptr.LChild != null) && (ptr.RChild != null))<br />
{<br />
if (ptr.LChild.RChild == null)
{<br />
ptr.Item = ptr.LChild.Item;<br />
ptr.LChild = ptr.LChild.LChild;<br />
}<br />
else<br />
{<br />
BTreeNode p = ptr.LChild;<br />
BTreeNode pp = ptr;
while (p.RChild != null)<br />
{<br />
pp = p;<br />
p = p.RChild;<br />
}<br />
ptr.Item = p.Item;<br />
pp.RChild = p.LChild;<br />
}<br />
}<br />
else
{<br />
BTreeNode c;<br />
if (ptr.LChild != null)<br />
c = ptr.LChild;<br />
else<br />
c = ptr.RChild;<br />
<br />
if (ptr == root)
root = c;<br />
else<br />
{<br />
if (ptr == parent.LChild)<br />
parent.LChild = c;<br />
else<br />
parent.RChild = c;<br />
}<br />
}<br />
<br />
}<br />
}<br />
<br />
public void PreOrderTraverse()<br />
{<br />
PreOrderTraverse(root);<br />
Console.WriteLine();<br />
}<br />
<br />
private void PreOrderTraverse(BTreeNode root)<br />
{<br />
if (root != null)<br />
{<br />
Console.Write(root.Item);<br />
PreOrderTraverse(root.LChild);<br />
PreOrderTraverse(root.RChild);<br />
}<br />
}<br />
<br />
public void InOrderTraverse()<br />
{<br />
InOrderTraverse(root);<br />
Console.WriteLine();<br />
}<br />
<br />
private void InOrderTraverse(BTreeNode root)<br />
{<br />
if (root != null)<br />
{<br />
InOrderTraverse(root.LChild);<br />
Console.WriteLine(root.Item);<br />
InOrderTraverse(root.RChild);<br />
}<br />
}<br />
<br />
public void PostOrderTraverse()<br />
{<br />
PostOrderTraverse(root);<br />
Console.WriteLine();<br />
}<br />
<br />
private void PostOrderTraverse(BTreeNode root)<br />
{<br />
if (root != null)<br />
{<br />
PostOrderTraverse(root.LChild);<br />
PostOrderTraverse(root.RChild);<br />
Console.Write(root.Item);<br />
}<br />
}<br />
<br />
public void Clear()<br />
{<br />
root = null;<br />
}<br />
<br />
public ArrayList AllItems()<br />
{<br />
ArrayList items = new ArrayList();<br />
AllItems(root, items);<br />
return items;<br />
}<br />
<br />
private void AllItems(BTreeNode root, ArrayList keys)<br />
{<br />
if (root != null)<br />
{<br />
AllItems(root.LChild, keys);<br />
keys.Add(root.Item);<br />
AllItems(root.RChild, keys);<br />
}<br />
}<br />
}<br />
<br />
using System;<br />
using System.Collections;<br />
<br />
namespace PatientName<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
int choice;<br />
IPatient p1 = new Patient();<br />
IBSTree container = new BSTree();<br />
Console.WriteLine("Enter the first Name of the patient:");<br />
p1.FirstName = Console.ReadLine();<br />
container.Insert(p1);<br />
<br />
}<br />
}<br />
}<br />
<br />
<br />
|
|
|
|
|
Tip: Use the pre tag when posting blocks of code. It makes it readable.
As far as I can see you only have overloads of the Insert method that takes an IComparable parameter. The Patient class doesn't implement the IComparable interface. Even if it would, the variable p1 is an IPatient reference, so it can never be used as an IComparable reference even if the actual ojbect would implement the IComparable interface.
Make the Patint class implement the IComparable interface, and change the variable p1 from an IPatient reference to a Patient reference.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
<pre>
//here is the IPatient implementation
using System;
using System.Collections;
public class Patient: IPatient, IComparable
{
private string fname;
public string FirstName
{
get
{
return fname;
}
set
{
fname = value;
}
}
public int CompareTo(Patient obj)
{
//Patient p1 = (Patient)obj;
return fname.CompareTo(p1.fname);
}
}
//the main method
using System;
using System.Collections;
namespace PatientName
{
class Program
{
static void Main(string[] args)
{
int choice;
Patient p1 = new Patient();
BSTree container = new BSTree();
Console.WriteLine("Enter the first Name of the patient:");
p1.FirstName = Console.ReadLine();
container.Insert(p1);
}
}
}
</pre>
|
|
|
|
|
The signature of CompareTo method will change like this
public int CompareTo(object obj){ You have to include a type checking of obj also
*jaans
|
|
|
|
|
And if i traverse the BST and try to output whats stored in BST it displays the Name of the ADT in my case "Patient" instead of the name of the people
|
|
|
|
|
You are using Console.WriteLine(root.Item); for output, but
root.Item<br /> is holding an IPatient object, so its displaying the type name itself.
If you want to display the FirstName cast the object and use the suitable properties.
*jaans
|
|
|
|
|
|
Modify your interface to implement IComparable interface
public interface IPatient:IComparable
{
string FirstName { get; set; }
} You may have to change your implementation of Patient class also accordingly.
*jaans
|
|
|
|
|
Yes i tried the solution you gave me earlier so i was wondering if i missed out something.
i get another error:
Doesnot implement interface member System.IComparable.CompareTo(Object);
|
|
|
|
|
see my comment to your earlier post.
*jaans
|
|
|
|
|
And if i traverse the BST and try to output whats stored in BST it displays the Name of the ADT in my case "Patient" instead of the name of the patient.
|
|
|
|
|
I have 3 doubts
1. I want to install DOTNET latest version in my computer. I dont have CD for installation. Which website would you suggest to get this done.
General Doubts
2. How to create
Internet and Show Desktop symbols on status bar
3. How to include
My Computer, My Documents , Network Neighbour symbols on desktop
|
|
|
|
|
What this has to do with c#?
Anyway the answers...
1. Microsoft download site
2. On status bar of what?
3. Use desktop properties
*jaans
|
|
|
|
|
1. Google.
2. Whose status bar?
3. TweakUI.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
Hi,
In my web application i am using a text area. How to display the & as & < as < , is there any way rather than using string.replace??
Please suggest me, if possible give me some link where i can learn.
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
You can try
& amp for ampersand (without the space)
AND
& lt for less than (without the space)
A quick way to look these up is to get a blank web page (aspx extension), type the symbols you want in "design" view, switch to "source" view and copy/paste the generated code for the symbol.
For example I put the characters onto a webpage and switched to source and got:
<form id="form1" runat="server">
<div>
&<br />
<</div>
</form>
Hope this helps
Chris
p.s. next time, this might be better in the Asp.Net forum rather then the C# forum
[Edit: My careful formatting doesnt seem to have copied very nicely so modified the post!]
|
|
|
|
|
Thank you very much for spending your valuable time and helping me. But i am expecting a better solution
Know is Drop, Unknown is Ocean
|
|
|
|