⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compare.cs

📁 按照Clifford A . Shaffer《数据结构与算法分析(第二版)》指导
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace DSwork
{
            // Some definitions for Comparator classes
    public interface ICompare<T>
    {
        bool lt(T x, T y);
        bool eq(T x, T y);
        bool gt(T x, T y);
    }

    public class intintCompare: ICompare<int>
    {
         public bool lt(int x, int y) { return x < y; }
         public bool eq(int x, int y) { return x == y; }
         public bool gt(int x, int y) { return x > y; }
    };

    public class strstrCompare : ICompare <string>
    {
        public bool lt(string x, string y) { return (string.Compare(x, y) < 0) ? true : false; }
        public bool eq(string x, string y) { return (string.Compare(x, y) == 0) ? true : false; }
        public bool gt(string x, string y) { return (string.Compare(x, y) > 0) ? true : false; }
    };

    //public class IntIntCompare
    //{
        
    //    public  static bool lt(Int x, Int y) { return x.key() < y.key(); }
    //    public  static bool eq(Int x, Int y) { return x.key() == y.key(); }
    //    public  static bool gt(Int x, Int y) { return x.key() > y.key(); }
    //    };

    //public class intIntCompare
    //{
        
    //    public  static bool lt(int x, Int y) { return x < y.key(); }
    //    public  static bool eq(int x, Int y) { return x == y.key(); }
    //    public  static bool gt(int x, Int y) { return x > y.key(); }
    //    };

    //public class intIntsCompare
    //{
        
    //    public static bool lt(int x, Int* y) { return x < y->key(); }
    //    public static bool eq(int x, Int* y) { return x == y->key(); }
    //    public static bool gt(int x, Int* y) { return x > y->key(); }
    //    };

    //public class IntsIntsCompare
    //{

    //    public static bool lt(Int* x, Int* y) { return x->key() < y->key(); }
    //    public static bool eq(Int* x, Int* y) { return x->key() == y->key(); }
    //    public static bool gt(Int* x, Int* y) { return x->key() > y->key(); }
    //    };

        /*class CCCompare {
        public:
          static bool lt(char* x, char* y) { return strcmp(x, y) < 0; }
          static bool eq(char* x, char* y) { return strcmp(x, y) == 0; }
          static bool gt(char* x, char* y) { return strcmp(x, y) > 0; }
        };
        */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -