本文整理汇总了C#中LinkedList.Max方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.Max方法的具体用法?C# LinkedList.Max怎么用?C# LinkedList.Max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkedList
的用法示例。
在下文中一共展示了LinkedList.Max方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsStabilized
static Func<Point, bool> IsStabilized()
{
const int maxVariance = 50;
var last10 = new LinkedList<Point>(new Point(0, 0).Repeat(50));
return currentPosition =>
{
last10.RemoveLast();
last10.AddFirst(currentPosition);
var xVariance = last10.Max(p => p.X) - last10.Min(p => p.X);
var yVariance = last10.Max(p => p.Y) - last10.Min(p => p.Y);
return xVariance < maxVariance && yVariance < maxVariance;
};
}
示例2: IsStabilized
static Func<Zipping.Pair<int, int>, bool> IsStabilized()
{
const int maxVariance = 50;
var last10 = new LinkedList<Zipping.Pair<int, int>>(new Zipping.Pair<int, int>(0, 0).Repeat(10));
return currentPosition =>
{
last10.RemoveLast();
last10.AddFirst(currentPosition);
var xVariance = last10.Max(p => p.First) - last10.Min(p => p.First);
var yVariance = last10.Max(p => p.Second) - last10.Min(p => p.Second);
return xVariance < maxVariance && yVariance < maxVariance;
};
}
示例3: Main
static void Main()
{
var list = new LinkedList<int>();
list.AddLast(1);
Console.WriteLine(list);
list.AddLast(2);
Console.WriteLine(list);
list.AddLast(3);
Console.WriteLine(list);
list.AddFirst(-1);
Console.WriteLine(list);
list.AddFirst(-2);
Console.WriteLine(list);
list.AddFirst(-3);
Console.WriteLine(list);
Console.WriteLine("Remove First: {0}", list.RemoveFirst().Value);
Console.WriteLine("Remove Last: {0}", list.RemoveLast().Value);
Console.WriteLine(list);
Console.WriteLine("Min: {0}; Max: {1}", list.Min(), list.Max());
Console.WriteLine("Contains 2: {0}", list.Contains(2));
Console.WriteLine("Count: {0}", list.Count);
}
示例4: SearchProperties
public ActionResult SearchProperties(FormCollection formCollection, int page = 1, string propertyResultsSort = "", int propertyResultsAmount = 25)
{
ViewBag.IdentifyPage = "Property Search";
Session["CurrentSearchResultsAmount"] = propertyResultsAmount;
Session["CurrentSearchResultsSort"] = propertyResultsSort;
//stick values into viewback for DDL update
ViewBag.propertyResultsSort = propertyResultsSort;
ViewBag.propertyResultsAmount = propertyResultsAmount;
//retrive values from post
//based on whether there are dates create either a booking search or property search
//create new object and populate - then run dynamic instance query on that object
int propertyTypeID = 0;
int vacationTypeID = 0;
string poolType = null;
int maxSleeps = 0;
int noOfAdults = 0;
int noOfChildren = 0;
int noOfInfants = 0;
DateTime? startDate = null;
DateTime? endDate = null; ;
try
{
//parse dates
if (formCollection["StartDate"] != "" && formCollection["StartDate"] != null)
{
startDate = DateTime.ParseExact(formCollection["StartDate"], "dd/MM/yyyy", CultureInfo.InvariantCulture);
}
if (formCollection["EndDate"] != "" && formCollection["EndDate"] != null)
{
endDate = DateTime.ParseExact(formCollection["EndDate"], "dd/MM/yyyy", CultureInfo.InvariantCulture);
}
if (formCollection["StartDate1"] != "" && formCollection["StartDate1"] != null)
{
startDate = DateTime.ParseExact(formCollection["StartDate1"], "dd/MM/yyyy", CultureInfo.InvariantCulture);
}
if (formCollection["EndDate1"] != "" && formCollection["EndDate1"] != null)
{
endDate = DateTime.ParseExact(formCollection["EndDate1"], "dd/MM/yyyy", CultureInfo.InvariantCulture);
}
//parse property Type ID
if (Int32.Parse(formCollection["PropertyType"]) != 0)
{
propertyTypeID = Int32.Parse(formCollection["PropertyType"]);
}
//parse region type
if (Int32.Parse(formCollection["RegionType"]) != 0)
{
vacationTypeID = Int32.Parse(formCollection["RegionType"]);
}
//parse poolType
if (formCollection["PoolType"] != "" && formCollection["PoolType"] != null && poolType != "0")
{
poolType = formCollection["PoolType"];
}
//parse max sleeps
if (Int32.Parse(formCollection["MaxSleeps"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["MaxSleeps"]);
}
//parse no of adults
if (Int32.Parse(formCollection["NoOfAdults"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["NoOfAdults"]);
}
//parse no of children
if (Int32.Parse(formCollection["NoOfChildren"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["NoOfChildren"]);
}
//parse no of infants
if (Int32.Parse(formCollection["NoOfInfants"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["NoOfInfants"]);
}
//parse price range
//jsut to account for if we haven't be passed a price
String[] splitPrice = "1-5000".Split('-');
if (formCollection["PriceRange"] != "" && formCollection["PriceRange"] != null)
{
splitPrice = null;
splitPrice = formCollection["PriceRange"].Split('-');
}
LinkedList<decimal> thePrices = new LinkedList<decimal>();
foreach (var thePrice in splitPrice)
{
int TryParseResult = 0;
//.........这里部分代码省略.........
示例5: LinkedListExtensions_Max_ThrowsExceptionIfLinkedListIsEmpty
public void LinkedListExtensions_Max_ThrowsExceptionIfLinkedListIsEmpty()
{
var list = new LinkedList<Int32>();
list.Max();
}
示例6: LinkedListExtensions_Max_ReturnsMaxValue
public void LinkedListExtensions_Max_ReturnsMaxValue()
{
var list = new LinkedList<Int32>();
list.AddLast(4);
list.AddLast(5);
list.AddLast(6);
list.AddLast(99);
list.AddLast(10);
list.AddLast(1);
list.AddLast(12);
list.AddLast(45);
var result = list.Max();
TheResultingValue(result).ShouldBe(99);
}
示例7: LinkedListExtensions_Max_ThrowsExceptionIfLinkedListIsEmpty
public void LinkedListExtensions_Max_ThrowsExceptionIfLinkedListIsEmpty()
{
var list = new LinkedList<Int32>();
Assert.That(() => list.Max(),
Throws.TypeOf<InvalidOperationException>());
}
示例8: SearchProperties
public ActionResult SearchProperties(FormCollection formCollection, int page = 1)
{
//retrive values from post
//based on whether there are dates create either a booking search or property search
//create new object and populate - then run dynamic instance query on that object
int propertyTypeID = 0;
int vacationTypeID = 0;
string poolType = null;
int maxSleeps = 0;
int noOfAdults = 0;
int noOfChildren = 0;
int noOfInfants = 0;
DateTime? startDate = null;
DateTime? endDate = null; ;
try
{
//parse dates
if (formCollection["bookingModalStartDatePicker"] != "" && formCollection["bookingModalStartDatePicker"] != null)
{
startDate = DateTime.Parse(formCollection["bookingModalStartDatePicker"]);
}
if (formCollection["EndDate"] != "" && formCollection["EndDate"] != null)
{
endDate = DateTime.Parse(formCollection["EndDate"]);
}
//parse property Type ID
if (Int32.Parse(formCollection["PropertyType"]) != 0)
{
propertyTypeID = Int32.Parse(formCollection["PropertyType"]);
}
//parse region type
if (Int32.Parse(formCollection["RegionType"]) != 0)
{
vacationTypeID = Int32.Parse(formCollection["RegionType"]);
}
//parse poolType
if (formCollection["PoolType"] != "" && formCollection["PoolType"] != null && poolType != "0")
{
poolType = formCollection["PoolType"];
}
//parse max sleeps
if (Int32.Parse(formCollection["MaxSleeps"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["MaxSleeps"]);
}
//parse no of adults
if (Int32.Parse(formCollection["NoOfAdults"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["NoOfAdults"]);
}
//parse no of children
if (Int32.Parse(formCollection["NoOfChildren"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["NoOfChildren"]);
}
//parse no of infants
if (Int32.Parse(formCollection["NoOfInfants"]) != 0)
{
maxSleeps = Int32.Parse(formCollection["NoOfInfants"]);
}
//parse price range
String[] splitPrice = "1-1000".Split('-');
if (formCollection["PriceRange"] != "" && formCollection["PriceRange"] != null)
{
splitPrice = null;
splitPrice = formCollection["PriceRange"].Split('-');
}
LinkedList<decimal> thePrices = new LinkedList<decimal>();
foreach (var thePrice in splitPrice)
{
int TryParseResult = 0;
//try parse to check it's a number
Int32.TryParse(thePrice.Trim().Replace("£", "").ToString(), out TryParseResult);
if (TryParseResult != 0)
{
thePrices.AddLast(Decimal.Parse(thePrice.Trim().Replace("£", "")));
}
}
//end parse price range
PriceRange customerQueryPriceRange = null;
if (thePrices.Count > 0)
{
customerQueryPriceRange = new PriceRange(thePrices.Min(), thePrices.Max());
}
else //pass the max range ever
{
customerQueryPriceRange = new PriceRange(0, 100000);
}
//END FORM PARSE
//.........这里部分代码省略.........