This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 其实第一眼,不用泛型不就得了吗,不进行封拆箱,我能想到是下面的 | |
class TicksToDateTimeCaller | |
{ | |
public object Call (dynamic arg) | |
{ | |
object result = null; | |
try | |
{ | |
result = new DateTime(arg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinkedSet<T> | |
where T : LinkedSetElement | |
{ | |
private LinkedSetLinker<T> _top; | |
private LinkedSetLinker<T> _bottom; | |
public void Add(T elem) | |
{ | |
LinkedSetLinker<T> linker = new LinkedSetLinker<T>(elem); | |
linker.Next = _top; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 希望这个会好点,但是Contains的时间复杂度高了 | |
class LinkedSet<T> | |
where T : class | |
{ | |
private List<T> _set = new List<T>(); | |
public void Add(T elem) | |
{ | |
_set.Add(elem); | |
} |