Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
cf95b27
3.1 Started
ikesnowy Jan 27, 2019
0727123
update readme to 3.1
ikesnowy Jan 27, 2019
dc7ecf9
3.1.1 Finished, #441
ikesnowy Jan 28, 2019
f63f16f
bug fix and code format, #441
ikesnowy Jan 28, 2019
59f4455
#442, 3.1.2 Finished
ikesnowy Feb 3, 2019
0f0fe7d
update readme
ikesnowy Feb 12, 2019
0d6725b
#443, Add Interface IOrderedST.
ikesnowy Feb 12, 2019
b7eafe3
#443, 3.1.3 Finished
ikesnowy Feb 12, 2019
b926401
3.1.4 Finished
ikesnowy Feb 13, 2019
e13427f
#444, 3.1.4 Finished
ikesnowy Feb 13, 2019
9c5a324
Merge branch 'dev' of https://github.com/ikesnowy/Algorithms-4th-Edit…
ikesnowy Feb 13, 2019
c742b0b
Add Auto-doc generator (docFX)
ikesnowy Feb 13, 2019
eaca145
remove contribution link for doc.
ikesnowy Feb 13, 2019
42ff65e
Add ShellSort Comment
ikesnowy Feb 14, 2019
1a443c9
Complete Document and Comment.
ikesnowy Feb 15, 2019
4ab5568
update README
ikesnowy Feb 15, 2019
7562306
#445, 3.1.5 Finished
ikesnowy Feb 15, 2019
08997e5
#446, 3.1.6 Finished
ikesnowy Feb 17, 2019
2de224f
#447, 3.1.7 Finished
ikesnowy Feb 17, 2019
665cc7b
#448, 3.1.8 Finished
ikesnowy Feb 17, 2019
486d437
#449, 3.1.9 Finished
ikesnowy Feb 19, 2019
27e4015
#450, 3.1.10 Finished
ikesnowy Feb 19, 2019
2fe071f
#450, Fix Mistaken Compare Time
ikesnowy Feb 19, 2019
103c872
Add Google Analytics in API Documents.
ikesnowy Feb 19, 2019
58cef71
#451, 3.1.11 Finished
ikesnowy Feb 20, 2019
fdd8520
#452, 3.1.12 Finished
ikesnowy Feb 23, 2019
76fdec1
#453, 3.1.13 Finished
ikesnowy Feb 23, 2019
39375c7
#454, 3.1.14 Finished
ikesnowy Feb 23, 2019
58a8ee6
#455, 3.1.15 Finished.
ikesnowy Feb 23, 2019
01c0c27
#456, 3.1.16 Finished.
ikesnowy Feb 24, 2019
a056c25
#457, 3.1.17 Finished.
ikesnowy Feb 24, 2019
a31983f
#458, 3.1.18 Finished.
ikesnowy Feb 24, 2019
5adce91
#459, 3.1.19 Finished.
ikesnowy Feb 25, 2019
13d1110
#460, 3.1.20 Finished.
ikesnowy Feb 27, 2019
7f3a436
#461, 3.1.21 Finished.
ikesnowy Feb 28, 2019
98b909a
#462, 3.1.22 Finished.
ikesnowy Feb 28, 2019
8d2fca0
#463,3.1.23 Finished.
ikesnowy Feb 28, 2019
8be45ac
#464, 3.1.24 Finished.
ikesnowy Mar 2, 2019
0d12ea7
#465, 3.1.25 Finished.
ikesnowy Mar 2, 2019
ca3e0eb
update readme
ikesnowy Mar 2, 2019
4ffc0df
#466, 3.1.26 Finished.
ikesnowy Mar 3, 2019
5f195b0
#467, 3.1.27Finished.
ikesnowy Mar 4, 2019
1798a66
#468, 3.1.28 Finished
ikesnowy Mar 4, 2019
1e465a1
#469, 3.1.29 Finished.
ikesnowy Mar 4, 2019
6e8595a
#469, bugfix
ikesnowy Mar 4, 2019
1389c68
#470, 3.1.30 Finished.
ikesnowy Mar 5, 2019
6c230d6
#471, 3.1.31 Finished.
ikesnowy Mar 7, 2019
f495c5e
#472, 3.1.32 Finished.
ikesnowy Mar 8, 2019
03c3c78
#473, 3.1.33 Finished
ikesnowy Mar 9, 2019
a242e1e
#474, 3.1.34 Finished
ikesnowy Mar 10, 2019
42aed18
#475, 3.1.35 Finished.
ikesnowy Mar 10, 2019
6598e34
#476, 3.1.36 Finished.
ikesnowy Mar 10, 2019
de3d36a
#474, Fix Harmonic Number Produce Bug
ikesnowy Mar 10, 2019
bbc7fe2
#477, 3.1.37 Finished
ikesnowy Mar 10, 2019
3be33f6
#478, 3.1.38 Finished
ikesnowy Mar 18, 2019
ba65cef
#479, 3.1.39 Finished
ikesnowy Mar 19, 2019
f4bab15
#480, 3.1.40 Finished
ikesnowy Mar 24, 2019
542af8e
#481, 3.1.41 Finished
ikesnowy Mar 24, 2019
59f29de
build 3.1 solution
ikesnowy Mar 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 24 additions & 8 deletions 1 Fundamental/1.2/Commercial/Date.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@

namespace Commercial
{
/// <summary>
/// 日期类。
/// </summary>
public class Date : IComparable<Date>
{
public int Month { get; } // 月
public int Day { get; } // 日
public int Year { get; } // 年
/// <summary>
/// 月份。
/// </summary>
/// <value>月份数据。</value>
public int Month { get; }
/// <summary>
/// 日期。
/// </summary>
/// <value>日期数据。</value>
public int Day { get; }
/// <summary>
/// 年份。
/// </summary>
/// <value>年份数据。</value>
public int Year { get; }

/// <summary>
/// 构造函数。
/// </summary>
/// <param name="date">形如 "05/31/2017" 的字符串。</param>
/// <exception cref="ArgumentException">输入日期格式不正确时抛出异常。</exception>
public Date(string date)
{
string[] a = date.Split('/');
Expand All @@ -36,9 +52,9 @@ public Date(int m, int d, int y)
}

/// <summary>
/// 返回形如 05/22/2017 的字符串
/// 将日期转换成字符串,格式为 dd/mm/yyyy
/// </summary>
/// <returns></returns>
/// <returns>形如 05/22/2017 的字符串。</returns>
public override string ToString()
{
return this.Month + "/" + this.Day + "/" + this.Year;
Expand All @@ -48,7 +64,7 @@ public override string ToString()
/// 比较两个日期是否相同。
/// </summary>
/// <param name="obj">需要比较的另一个对象。</param>
/// <returns></returns>
/// <returns>相等返回 <c>true</c>,否则返回 <c>false</c>。</returns>
public override bool Equals(object obj)
{
if (obj == this)
Expand All @@ -64,7 +80,7 @@ public override bool Equals(object obj)
/// <summary>
/// 获取日期的哈希值。
/// </summary>
/// <returns></returns>
/// <returns>日期的哈希值。</returns>
public override int GetHashCode()
{
int hash = 17;
Expand All @@ -78,7 +94,7 @@ public override int GetHashCode()
/// 比较两个日期的先后。
/// </summary>
/// <param name="other">另一个日期。</param>
/// <returns></returns>
/// <returns><paramref name="other"/> 较后时返回大于 0 的数,反之返回小于 0 的数,相等返回 0。</returns>
public int CompareTo(Date other)
{
if (this.Year > other.Year)
Expand Down
36 changes: 35 additions & 1 deletion 1 Fundamental/1.2/Commercial/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@

namespace Commercial
{
/// <summary>
/// 交易记录类。
/// </summary>
public class Transaction : IComparable<Transaction>
{
/// <summary>
/// 客户姓名。
/// </summary>
/// <value>客户姓名。</value>
public string Who { get; }
/// <summary>
/// 交易日期。
/// </summary>
/// <value>交易日期。</value>
/// <seealso cref="Date"/>
public Date When { get; }
/// <summary>
/// 交易金额。
/// </summary>
/// <value>交易金额。</value>
public double Amount { get; }

/// <summary>
Expand Down Expand Up @@ -66,6 +82,12 @@ public int CompareTo(Transaction other)
/// </summary>
public class WhoOrder : IComparer<Transaction>
{
/// <summary>
/// 比较两个 <see cref="Transaction"/> 的姓名。
/// </summary>
/// <param name="x">需要比较的第一个记录。</param>
/// <param name="y">需要比较的第二个记录。</param>
/// <returns><paramref name="x"/> 姓名靠后时返回大于 0 的数,反之返回小于 0 的数,相等返回 0。</returns>
int IComparer<Transaction>.Compare(Transaction x, Transaction y)
{
return x.Who.CompareTo(y.Who);
Expand All @@ -77,6 +99,12 @@ int IComparer<Transaction>.Compare(Transaction x, Transaction y)
/// </summary>
public class WhenOrder : IComparer<Transaction>
{
/// <summary>
/// 比较两个 <see cref="Transaction"/> 的交易时间。
/// </summary>
/// <param name="x">需要比较的第一个记录。</param>
/// <param name="y">需要比较的第二个记录。</param>
/// <returns><paramref name="x"/> 时间靠后时返回大于 0 的数,反之返回小于 0 的数,相等返回 0。</returns>
int IComparer<Transaction>.Compare(Transaction x, Transaction y)
{
return x.When.CompareTo(y.When);
Expand All @@ -88,6 +116,12 @@ int IComparer<Transaction>.Compare(Transaction x, Transaction y)
/// </summary>
public class HowMuchOrder : IComparer<Transaction>
{
/// <summary>
/// 比较两个 <see cref="Transaction"/> 的交易金额。
/// </summary>
/// <param name="x">需要比较的第一个记录。</param>
/// <param name="y">需要比较的第二个记录。</param>
/// <returns><paramref name="x"/> 金额较大时返回大于 0 的数,反之返回小于 0 的数,相等返回 0。</returns>
int IComparer<Transaction>.Compare(Transaction x, Transaction y)
{
return x.Amount.CompareTo(y.Amount);
Expand Down Expand Up @@ -118,7 +152,7 @@ public override bool Equals(object obj)
/// <summary>
/// 返回交易信息的哈希值。
/// </summary>
/// <returns></returns>
/// <returns>交易信息的哈希值。</returns>
public override int GetHashCode()
{
int hash = 1;
Expand Down
32 changes: 27 additions & 5 deletions 1 Fundamental/1.2/Geometry/Interval1D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,33 @@ namespace Geometry
/// </summary>
public class Interval1D
{
/// <summary>
/// 优先以起点升序排序,起点相同时按照终点升序排序。
/// </summary>
/// <value>优先以起点升序排序,起点相同时按照终点升序排序。</value>
public static readonly Comparer<Interval1D> Min_Order = new MinEndpointComparer();
/// <summary>
/// 优先以终点升序排序,起点相同时按照起点升序排序。
/// </summary>
/// <value>优先以终点升序排序,起点相同时按照起点升序排序。</value>
public static readonly Comparer<Interval1D> Max_Order = new MaxEndpointComparer();
/// <summary>
/// 以区间长度升序排序。
/// </summary>
/// <value>以区间长度升序排序。</value>
public static readonly Comparer<Interval1D> Length_Order = new LengthComparer();

/// <summary>
/// 区间起点。
/// </summary>
/// <value>区间起点。</value>
/// <remarks>这个属性是只读的。</remarks>
public double Min { get; }
/// <summary>
/// 区间终点。
/// </summary>
/// <value>区间终点。</value>
/// <remarks>这个属性是只读的。</remarks>
public double Max { get; }

/// <summary>
Expand Down Expand Up @@ -56,7 +78,7 @@ public double Length()
/// 判断目标区间是否被本区间包含。
/// </summary>
/// <param name="that">需要判断是否被包含的区间。</param>
/// <returns></returns>
/// <returns>若 <paramref name="that"/> 被本区间包含则返回 <c>true</c>,否则返回 <c>false</c>。</returns>
public bool Contains(Interval1D that)
{
return this.Min < that.Min && this.Max > that.Max;
Expand All @@ -66,7 +88,7 @@ public bool Contains(Interval1D that)
/// 目标值是否处在区域内。如果目标值在区域内则返回 True,否则返回 False。
/// </summary>
/// <param name="x">需要判断的值。</param>
/// <returns></returns>
/// <returns>若 <paramref name="x"/> 被本区间包含则返回 <c>true</c>,否则返回 <c>false</c>。</returns>
public bool Contains(double x)
{
return x >= this.Min && x <= this.Max;
Expand Down Expand Up @@ -100,7 +122,7 @@ public void Draw(Graphics g, int y)
/// <summary>
/// 将区域转换为 string,返回形如 "[lo, hi]" 的字符串。
/// </summary>
/// <returns></returns>
/// <returns>形如 "[<see cref="Min"/>, <see cref="Max"/>]" 的字符串。</returns>
public override string ToString()
{
string s = "[" + this.Min + ", " + this.Max + "]";
Expand All @@ -111,7 +133,7 @@ public override string ToString()
/// 判断两个区间是否相等。
/// </summary>
/// <param name="obj">相比较的区间。</param>
/// <returns></returns>
/// <returns>如果区间相等则返回 <c>true</c>,否则返回 <c>false</c>。</returns>
public override bool Equals(object obj)
{
if (obj == this)
Expand All @@ -133,7 +155,7 @@ public override bool Equals(object obj)
/// <summary>
/// 返回区间的哈希代码。
/// </summary>
/// <returns></returns>
/// <returns>返回区间的哈希代码。</returns>
public override int GetHashCode()
{
int hash1 = this.Min.GetHashCode();
Expand Down
14 changes: 7 additions & 7 deletions 1 Fundamental/1.2/Geometry/Interval2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Interval2D(Interval1D x, Interval1D y)
/// 判断两个平面是否相交。
/// </summary>
/// <param name="that">需要判断的另一个平面。</param>
/// <returns></returns>
/// <returns>相交则返回 <c>true</c>,否则返回 <c>false</c>。</returns>
public bool Intersects(Interval2D that)
{
if (!this.X.Intersect(that.X))
Expand All @@ -45,7 +45,7 @@ public bool Intersects(Interval2D that)
/// 判断目标区间是否被本区间包含。
/// </summary>
/// <param name="that">需要判断是否被包含的区间。</param>
/// <returns></returns>
/// <returns>如果 <paramref name="that"/> 被包含,则返回 <c>true</c>,否则返回 <c>false</c>。</returns>
public bool Contains(Interval2D that)
{
return this.X.Contains(that.X) && this.Y.Contains(that.Y);
Expand All @@ -55,7 +55,7 @@ public bool Contains(Interval2D that)
/// 判断一个二维点是否在该平面范围内。
/// </summary>
/// <param name="p">需要判断的二维点。</param>
/// <returns></returns>
/// <returns>如果 <paramref name="p"/> 被包含,则返回 <c>true</c>,否则 <c>false</c>。</returns>
public bool Contains(Point2D p)
{
return (this.X.Contains(p.X) && this.Y.Contains(p.Y));
Expand All @@ -64,7 +64,7 @@ public bool Contains(Point2D p)
/// <summary>
/// 计算平面范围的面积。
/// </summary>
/// <returns></returns>
/// <returns>平面范围的面积。</returns>
public double Area()
{
return this.X.Length() * this.Y.Length();
Expand All @@ -84,7 +84,7 @@ public void Draw(Graphics g)
/// <summary>
/// 返回形如“[xmin, xmax] x [ymin, ymax]”的字符串。
/// </summary>
/// <returns></returns>
/// <returns>形如 "[xmin, xmax] x [ymin, ymax]" 的字符串。</returns>
public override string ToString()
{
return this.X + "x" + this.Y;
Expand All @@ -94,7 +94,7 @@ public override string ToString()
/// 判断两个二维区间是否相等。
/// </summary>
/// <param name="obj">需要比较的另一个区间。</param>
/// <returns></returns>
/// <returns>相等则返回 <c>true</c>,否则返回 <c>false</c>。</returns>
public override bool Equals(object obj)
{
if (obj == this)
Expand All @@ -119,7 +119,7 @@ public override bool Equals(object obj)
/// <summary>
/// 获取哈希值
/// </summary>
/// <returns></returns>
/// <returns>2D 区间的哈希值。</returns>
public override int GetHashCode()
{
int hash1 = this.X.GetHashCode();
Expand Down
Loading