*紧急*为什么我收到此代码的错误? (优先级队列) [英] *URGENT* Why am I getting an error for this code? (Priority Queue)
问题描述
所以,这可能是一个愚蠢的问题,但基本上,我在C#中有一个处理霍夫曼代码的任务,我的教授给了我们以下所有代码"骨架"。我们必须使用它们,我们只需要填写所有内容。由于
这个方法没有返回值,但行"PriorityQueue< Node>" PQ;"加下划线说"无法找到类型或命名空间名称'PriorityQueue<>'。"我该如何解决这个错误?当
我在类和方法中进行编码时,它会被解决,还是其他什么?
So, this is probably a dumb question but basically, I have an assignment in C# dealing with Huffman codes and my prof gave us all the following code "skeleton" that we HAVE to use and we just have to fill it all in. Some are underlined due to the fact that the method isn't returning a value, but the line "PriorityQueue<Node> PQ;" is underlined saying "The type or namespace name 'PriorityQueue<>' could not be found." How do I fix this error? Will it be resolved when I am doing the coding within the classes and methods, or is it something else?
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
namespace Huffman_Codes
{
class Node : IComparable
{
public char Character { get; set; }
public int Frequency { get; set; }
public Node Left { get; set; }
public Node Right { get; set; }
public Node (char character, int frequency, Node left, Node right)
{
}
public int CompareTo (Object obj)
{
}
}
class Huffman
{
private Node HT; // Huffman tree to create codes and decode text
private Dictionary<char, string> D; // Dictionary to encode text
// Constructor
public Huffman (string S)
{
}
// Return the frequency of each character in the given text (invoked by Huffman)
private int[] AnalyzeText (string S)
{
}
// Build a Huffman tree based on the character frequencies greater than 0 (invoked by Huffman)
private void Build ( int[] F)
{
PriorityQueue<Node> PQ;
}
// Create the code of 0s and 1s for each character by traversing the Huffman tree (invoked by Huffman)
private void CreateCodes ()
{
}
// Encode the given text and return a string of 0s and 1s
public string Encode (string S)
{
}
// Decode the given string of 0s and 1s and return the original text
public string Decode (string S)
{
}
}
}
推荐答案
你可以只返回null或者引发异常,所以你的程序是可构建的......
you can just return null or thow an exception, so your program is buildable...
class Node : IComparable
{
public char Character { get; set; }
public int Frequency { get; set; }
public Node Left { get; set; }
public Node Right { get; set; }
public Node(char character, int frequency, Node left, Node right)
{
}
public int CompareTo(Object obj)
{
throw new NotImplementedException(); //Remove later
}
}
class Huffman
{
private Node HT; // Huffman tree to create codes and decode text
private Dictionary<char, string> D; // Dictionary to encode text
// Constructor
public Huffman(string S)
{
}
// Return the frequency of each character in the given text (invoked by Huffman)
private int[] AnalyzeText(string S)
{
return null; //Remove later
}
// Build a Huffman tree based on the character frequencies greater than 0 (invoked by Huffman)
private void Build(int[] F)
{
PriorityQueue<Node> PQ;
}
// Create the code of 0s and 1s for each character by traversing the Huffman tree (invoked by Huffman)
private void CreateCodes()
{
}
// Encode the given text and return a string of 0s and 1s
public string Encode(string S)
{
return null; //Remove later
}
// Decode the given string of 0s and 1s and return the original text
public string Decode(string S)
{
throw new NotImplementedException(); //Remove later
}
}
错误与优先级问题,我猜你在另一个版本中与你的教授实施了一个课程,现在你必须使用它...
And the error with PriorityQueue, I guess you implemented a class with your prof in another lession and now you have to use it...
问候,克里斯
这篇关于*紧急*为什么我收到此代码的错误? (优先级队列)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!