private IEnumerator Show(SequenceElement element) { yield return(new WaitForSeconds(element.fromTime)); if (element.sprite != null) { ImageManager.instance.Show(element.sprite); } if (element.text != "") { TextManager.instance.Show(element.text); } if (element.toTime >= 0f) { yield return(new WaitForSeconds(element.toTime - element.fromTime)); if (element.sprite != null) { ImageManager.instance.Hide(element.sprite); } if (element.text != "") { TextManager.instance.Hide(element.text); } } }
/// <summary> /// Helper method used to create a share usage instance. /// </summary> private void CreateShareUsage(double sharePercentage, int minimumEntriesPerMessage, int interval, List <string> blockedHeaders, List <string> includedQueryStringParams, List <KeyValuePair <string, string> > ignoreDataEvidenceFiler, bool shareAll = false) { _sequenceElement = new SequenceElement(new Mock <ILogger <SequenceElement> >().Object); _sequenceElement.AddPipeline(_pipeline.Object); _shareUsageElement = new ShareUsageElement( _logger.Object, _httpClient, sharePercentage, minimumEntriesPerMessage, minimumEntriesPerMessage * 2, 100, 100, interval, true, "http://51Degrees.com/test", blockedHeaders, includedQueryStringParams, ignoreDataEvidenceFiler, Engines.Constants.DEFAULT_ASP_COOKIE_NAME, _tracker.Object, shareAll); _shareUsageElement.AddPipeline(_pipeline.Object); }
private static int MoveOrgIfNeeded(int whereIsOrg, SequenceElement org, int delta) { if (org == null) { return(1); } if (whereIsOrg != org.Button) { if (whereIsOrg < org.Button) { whereIsOrg += delta; if (whereIsOrg > org.Button) { whereIsOrg = org.Button; } } else { whereIsOrg -= delta; if (whereIsOrg < org.Button) { whereIsOrg = org.Button; } } } return(whereIsOrg); }
/// <summary> /// Copy constructor. /// </summary> public SequenceElement(SequenceElement seqel) { Volume = seqel.Volume; ScriptFunction = seqel.ScriptFunction; When = new Time(seqel.When); Duration = new Time(seqel.Duration); Notes = new List <double>(seqel.Notes); }
private void viewModel_ExpansionUpdateNeeded(object sender, CustomEventArgs <ExpansionUpdateEvent> e) { SequenceElement sequenceElement = sender as SequenceElement; DependencyObject dObject = null; ExpansionUpdateEvent updateEvent = e.Value; if (updateEvent == ExpansionUpdateEvent.Filter) { ExpandMatchedNode(sender); // Keeping way open for future filtering feature } else { if (this.viewModel.SelectedAnimationElementRoot != null && this.viewModel.SelectedAnimationParent != null) { if (this.viewModel.SelectedAnimationElement is SequenceElement) // Sequence within a sequence { TreeViewItem item = treeViewAnimations.ItemContainerGenerator.ContainerFromItem(this.viewModel.SelectedAnimationElementRoot) as TreeViewItem; dObject = FindTreeViewItemUnderTreeViewItemByModelName(item, this.viewModel.SelectedAnimationElement.Name); } else if (this.viewModel.SelectedAnimationElementRoot.Name == this.viewModel.SelectedAnimationParent.Name) // They are the same element { dObject = treeViewAnimations.GetItemFromSelectedObject(this.viewModel.SelectedAnimationParent); } else { TreeViewItem item = treeViewAnimations.ItemContainerGenerator.ContainerFromItem(this.viewModel.SelectedAnimationElementRoot) as TreeViewItem; dObject = FindTreeViewItemUnderTreeViewItemByModelName(item, this.viewModel.SelectedAnimationParent.Name); } } else if (this.viewModel.SelectedAnimationElementRoot == null && this.viewModel.SelectedAnimationElement is SequenceElement) { dObject = treeViewAnimations.GetItemFromSelectedObject(this.viewModel.SelectedAnimationElement); } TreeViewItem tvi = dObject as TreeViewItem; if (tvi != null) { AnimationElement model = tvi.DataContext as AnimationElement; if (tvi.Items != null && tvi.Items.Count > 0) { if (updateEvent != ExpansionUpdateEvent.Delete) { tvi.IsExpanded = true; } else { UpdateExpansions(tvi); } } else { tvi.IsExpanded = false; } } } }
private IEnumerator StartCameraRoaming() { yield return(new WaitForEndOfFrame()); yield return(StartCoroutine(UIController.FadeInOut(false))); SequenceElement se = components[currentIndex]; while (true) { if (currentIndex >= components.Count) { break; } if (se.type == SequenceType.Position || se.type == SequenceType.Simultaneous) { main_cam.transform.position = Vector3.Lerp(main_cam.transform.position, se.targetPosition, 1.0f / se.duration * Time.deltaTime); } if (se.type == SequenceType.Rotation || se.type == SequenceType.Simultaneous) { main_cam.transform.rotation = Quaternion.Slerp(main_cam.transform.rotation, Quaternion.Euler(se.targetEulerAngles), 1.0f / se.duration * Time.deltaTime); } if (se.type == SequenceType.Position) { if (Vector3.Distance(se.targetPosition, main_cam.transform.position) < 0.5f) { main_cam.transform.position = se.targetPosition; currentIndex++; yield return(new WaitForSeconds(Time.deltaTime)); } } else if (se.type == SequenceType.Rotation) { if (Vector3.Distance(se.targetEulerAngles, main_cam.transform.rotation.eulerAngles) < 5f) { main_cam.transform.rotation = Quaternion.Euler(se.targetEulerAngles); currentIndex++; yield return(new WaitForSeconds(Time.deltaTime)); } } else { if (Vector3.Distance(se.targetEulerAngles, main_cam.transform.rotation.eulerAngles) < 5f && Vector3.Distance(se.targetPosition, main_cam.transform.position) < 0.5f) { main_cam.transform.position = se.targetPosition; main_cam.transform.rotation = Quaternion.Euler(se.targetEulerAngles); currentIndex++; yield return(new WaitForSeconds(Time.deltaTime)); } } } yield return(StartCoroutine(UIController.FadeInOut(true))); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Issuer != null) { result.AddRange(Issuer.Validate()); } if (Period != null) { result.AddRange(Period.Validate()); } if (Type != null) { result.AddRange(Type.Validate()); } if (Identifier != null) { result.AddRange(Identifier.Validate()); } if (Group != null) { result.AddRange(Group.Validate()); } if (Plan != null) { result.AddRange(Plan.Validate()); } if (Subplan != null) { result.AddRange(Subplan.Validate()); } if (DependentElement != null) { result.AddRange(DependentElement.Validate()); } if (SequenceElement != null) { result.AddRange(SequenceElement.Validate()); } if (Subscriber != null) { result.AddRange(Subscriber.Validate()); } return(result); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as SubunitComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (SubunitElement != null) { dest.SubunitElement = (Hl7.Fhir.Model.Integer)SubunitElement.DeepCopy(); } if (SequenceElement != null) { dest.SequenceElement = (Hl7.Fhir.Model.FhirString)SequenceElement.DeepCopy(); } if (LengthElement != null) { dest.LengthElement = (Hl7.Fhir.Model.Integer)LengthElement.DeepCopy(); } if (SequenceAttachment != null) { dest.SequenceAttachment = (Hl7.Fhir.Model.Attachment)SequenceAttachment.DeepCopy(); } if (NTerminalModificationId != null) { dest.NTerminalModificationId = (Hl7.Fhir.Model.Identifier)NTerminalModificationId.DeepCopy(); } if (NTerminalModificationElement != null) { dest.NTerminalModificationElement = (Hl7.Fhir.Model.FhirString)NTerminalModificationElement.DeepCopy(); } if (CTerminalModificationId != null) { dest.CTerminalModificationId = (Hl7.Fhir.Model.Identifier)CTerminalModificationId.DeepCopy(); } if (CTerminalModificationElement != null) { dest.CTerminalModificationElement = (Hl7.Fhir.Model.FhirString)CTerminalModificationElement.DeepCopy(); } return(dest); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as SubunitComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (SubunitElement != null) { dest.SubunitElement = (Hl7.Fhir.Model.Integer)SubunitElement.DeepCopy(); } if (SequenceElement != null) { dest.SequenceElement = (Hl7.Fhir.Model.FhirString)SequenceElement.DeepCopy(); } if (LengthElement != null) { dest.LengthElement = (Hl7.Fhir.Model.Integer)LengthElement.DeepCopy(); } if (SequenceAttachment != null) { dest.SequenceAttachment = (Hl7.Fhir.Model.Attachment)SequenceAttachment.DeepCopy(); } if (FivePrime != null) { dest.FivePrime = (Hl7.Fhir.Model.CodeableConcept)FivePrime.DeepCopy(); } if (ThreePrime != null) { dest.ThreePrime = (Hl7.Fhir.Model.CodeableConcept)ThreePrime.DeepCopy(); } if (Linkage != null) { dest.Linkage = new List <Hl7.Fhir.Model.SubstanceNucleicAcid.LinkageComponent>(Linkage.DeepCopy()); } if (Sugar != null) { dest.Sugar = new List <Hl7.Fhir.Model.SubstanceNucleicAcid.SugarComponent>(Sugar.DeepCopy()); } return(dest); }
SequenceElement parseSequenceElementRow(String input) { String[] commaSplit = input.Split(','); // Behandle ganze Zeile SequenceElement[] elements = new SequenceElement[commaSplit.Length - 2]; for (int j = 2; j < commaSplit.Length; j++) { elements[j - 2] = parseSequenceElement(commaSplit[j]); } SequenceElement seq = new Sequence( Int32.Parse(commaSplit[0]), Convert.ToBoolean(commaSplit[1]), elements ); return(seq); }
// Loads List of Data Objects void LoadProcedure(string filepath) { string objectfile = filepath + "procedure.txt"; if (File.Exists(objectfile)) { // Iterate through Object list String data = File.ReadAllText(objectfile); generateDictionaryAndArray(data); SequenceElement parsed = this.parseSequenceElementRow(sequenceArray[0]); PersistentManager.Instance.procedure = parsed; PersistentManager.Instance.setProceduretarget(parsed.GetTargetInteractionCount()); } else { Debug.LogError("Did not load Procedure. File not found: " + objectfile); } }
private void treeViewAnimations_PreviewDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(Constants.ANIMATION_DRAG_KEY)) { TreeViewItem itemNode; FindDropTarget((TreeView)sender, out itemNode, e); if (itemNode != null) { AnimationElement dropAnimationElement = (itemNode != null && itemNode.IsVisible ? itemNode.DataContext as AnimationElement : null); AnimationElement dragAnimationElement = e.Data.GetData(Constants.ANIMATION_DRAG_KEY) as AnimationElement; SequenceElement dropAnimationElementParent = null; if (dropAnimationElement is SequenceElement) { itemNodeParent = itemNode; dropAnimationElementParent = dropAnimationElement as SequenceElement; } else { itemNodeParent = GetImmediateTreeViewItemParent(itemNode); dropAnimationElementParent = itemNodeParent != null ? itemNodeParent.DataContext as SequenceElement : null; } try { if (dragAnimationElement is AnimatedAbility) { // Drag drop of Reference Ability this.viewModel.MoveReferenceAbilityToAnimationElements(dragAnimationElement as AnimatedAbility, dropAnimationElementParent, dropAnimationElement.Order); } else { // Drag drop of animations this.viewModel.MoveSelectedAnimationElement(dropAnimationElementParent, dropAnimationElement.Order); } } catch (Exception ex) { } } } }
private void GenerateNextWall() { SequenceElement element = sequenceGeneration.GetNextSequenceElement(); if (element == SequenceElement.Top) { GameObject wall = wallPolling.GetWall(); StartCoroutine(wallSequenceGeneration.GenerateWallSequenece(wall.GetComponentInChildren <Wall>())); wall.transform.position = positionTop.position; WallMovement wallMovement = wall.GetComponent <WallMovement>(); wallMovement.Direction = Vector2.down; } else { if (element == SequenceElement.Down) { GameObject wall = wallPolling.GetWall(); StartCoroutine(wallSequenceGeneration.GenerateWallSequenece(wall.GetComponentInChildren <Wall>())); wall.transform.position = positionBottom.position; WallMovement wallMovement = wall.GetComponent <WallMovement>(); wallMovement.Direction = Vector2.up; } else { GameObject wallTop = wallPolling.GetWall(); GameObject wallBottom = wallPolling.GetWall(); StartCoroutine(wallSequenceGeneration.GenerateWallSequenece(wallTop.GetComponentInChildren <Wall>(), wallBottom.GetComponentInChildren <Wall>())); wallTop.transform.position = positionTop.position; WallMovement wallTopMovement = wallTop.GetComponent <WallMovement>(); wallTopMovement.Direction = Vector2.down; wallBottom.transform.position = positionBottom.position; WallMovement wallBottomMovement = wallBottom.GetComponent <WallMovement>(); wallBottomMovement.Direction = Vector2.up; } } AddWallGenerationTimer(); }
public void Handle(GameKeyEvent message) { if (!IsActive || IsPopupShowing) { return; } if (message.PlayerAction == PlayerAction.Back) { PauseRecord(); IsPopupShowing = true; _eventAggregator.Publish(new ShowPopupEvent() { PopupType = PopupType.ButtonsPopup, PopupSettings = (vm) => { (vm as ButtonsPopupViewModel).Buttons.AddRange(new List <string>() { "Resume", "Play again", "Save the sequence", "Go back" }); (vm as ButtonsPopupViewModel).Message = "Pause"; (vm as ButtonsPopupViewModel).PopupId = 1; } }); } else if (message.PlayerAction == PlayerAction.Enter) { StartRecord(); } else if (_musicPlayerService.IsRunning) { ISequenceElement seqElem = new SequenceElement() { IsBomb = message.PlayerId == PlayerID.Player2, Time = _animation.GetCurrentTime(), Type = GameHelper.PlayerActionToSeqElemType(message.PlayerAction) }; AddNote(seqElem); } }
// Verify boundary cases and add UTs // Refactor public int RunAlgo(string seq) { // State based simulation run Queue <SequenceElement> blueSeq = null; Queue <SequenceElement> orgSeq = null; GetTwoQueuesFrom(seq, out blueSeq, out orgSeq); int timePassed = 0; int whereIsBlue = 1; int whereIsOrg = 1; SequenceElement blue = GetNext(blueSeq); SequenceElement org = GetNext(orgSeq); while (blue != null && org != null) { if (blue.SeqNum < org.SeqNum) { Process(blueSeq, ref timePassed, ref whereIsBlue, ref whereIsOrg, ref blue, org); } else { Process(orgSeq, ref timePassed, ref whereIsOrg, ref whereIsBlue, ref org, blue); } } while (blue != null) { Process(blueSeq, ref timePassed, ref whereIsBlue, ref whereIsOrg, ref blue, org); } while (org != null) { Process(orgSeq, ref timePassed, ref whereIsOrg, ref whereIsBlue, ref org, blue); } return(timePassed); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as LineItemComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (SequenceElement != null) { dest.SequenceElement = (Hl7.Fhir.Model.PositiveInt)SequenceElement.DeepCopy(); } if (ChargeItem != null) { dest.ChargeItem = (Hl7.Fhir.Model.Element)ChargeItem.DeepCopy(); } if (PriceComponent != null) { dest.PriceComponent = new List <Hl7.Fhir.Model.Invoice.PriceComponentComponent>(PriceComponent.DeepCopy()); } return(dest); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Coverage; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Issuer != null) { dest.Issuer = (Hl7.Fhir.Model.ResourceReference)Issuer.DeepCopy(); } if (Bin != null) { dest.Bin = (Hl7.Fhir.Model.Identifier)Bin.DeepCopy(); } if (Period != null) { dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy(); } if (Type != null) { dest.Type = (Hl7.Fhir.Model.Coding)Type.DeepCopy(); } if (SubscriberId != null) { dest.SubscriberId = (Hl7.Fhir.Model.Identifier)SubscriberId.DeepCopy(); } if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (GroupElement != null) { dest.GroupElement = (Hl7.Fhir.Model.FhirString)GroupElement.DeepCopy(); } if (PlanElement != null) { dest.PlanElement = (Hl7.Fhir.Model.FhirString)PlanElement.DeepCopy(); } if (SubPlanElement != null) { dest.SubPlanElement = (Hl7.Fhir.Model.FhirString)SubPlanElement.DeepCopy(); } if (DependentElement != null) { dest.DependentElement = (Hl7.Fhir.Model.PositiveInt)DependentElement.DeepCopy(); } if (SequenceElement != null) { dest.SequenceElement = (Hl7.Fhir.Model.PositiveInt)SequenceElement.DeepCopy(); } if (Subscriber != null) { dest.Subscriber = (Hl7.Fhir.Model.ResourceReference)Subscriber.DeepCopy(); } if (Network != null) { dest.Network = (Hl7.Fhir.Model.Identifier)Network.DeepCopy(); } if (Contract != null) { dest.Contract = new List <Hl7.Fhir.Model.ResourceReference>(Contract.DeepCopy()); } return(dest); }
private int MoveBlueToSeqNum(SequenceElement blue, int whereIsBlue, out int delta) { delta = Math.Abs(blue.Button - whereIsBlue); return(blue.Button); }
private void Process(Queue <SequenceElement> blueSeq, ref int timePassed, ref int whereIsBlue, ref int whereIsOrg, ref SequenceElement blue, SequenceElement org) { if (whereIsBlue == blue.Button) { timePassed++; // pressed. blue = GetNext(blueSeq); whereIsOrg = MoveOrgIfNeeded(whereIsOrg, org, 1); } else { int delta = 0; whereIsBlue = MoveBlueToSeqNum(blue, whereIsBlue, out delta); timePassed += delta; whereIsOrg = MoveOrgIfNeeded(whereIsOrg, org, delta); } }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Dosage; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (SequenceElement != null) { dest.SequenceElement = (Hl7.Fhir.Model.Integer)SequenceElement.DeepCopy(); } if (TextElement != null) { dest.TextElement = (Hl7.Fhir.Model.FhirString)TextElement.DeepCopy(); } if (AdditionalInstruction != null) { dest.AdditionalInstruction = new List <Hl7.Fhir.Model.CodeableConcept>(AdditionalInstruction.DeepCopy()); } if (PatientInstructionElement != null) { dest.PatientInstructionElement = (Hl7.Fhir.Model.FhirString)PatientInstructionElement.DeepCopy(); } if (Timing != null) { dest.Timing = (Hl7.Fhir.Model.Timing)Timing.DeepCopy(); } if (AsNeeded != null) { dest.AsNeeded = (Hl7.Fhir.Model.DataType)AsNeeded.DeepCopy(); } if (Site != null) { dest.Site = (Hl7.Fhir.Model.CodeableConcept)Site.DeepCopy(); } if (Route != null) { dest.Route = (Hl7.Fhir.Model.CodeableConcept)Route.DeepCopy(); } if (Method != null) { dest.Method = (Hl7.Fhir.Model.CodeableConcept)Method.DeepCopy(); } if (DoseAndRate != null) { dest.DoseAndRate = new List <Hl7.Fhir.Model.Dosage.DoseAndRateComponent>(DoseAndRate.DeepCopy()); } if (MaxDosePerPeriod != null) { dest.MaxDosePerPeriod = (Hl7.Fhir.Model.Ratio)MaxDosePerPeriod.DeepCopy(); } if (MaxDosePerAdministration != null) { dest.MaxDosePerAdministration = (Hl7.Fhir.Model.Quantity)MaxDosePerAdministration.DeepCopy(); } if (MaxDosePerLifetime != null) { dest.MaxDosePerLifetime = (Hl7.Fhir.Model.Quantity)MaxDosePerLifetime.DeepCopy(); } return(dest); }
public bool CheckPasteEligibilityFromClipboard(AnimationSequencer destinationSequence) { bool canPaste = false; switch (this.CurrentClipboardAction) { case ClipboardAction.Clone: if (this.currentClipboardObject != null) { if (this.currentClipboardObject is AnimationSequencer) { AnimationSequencer seqElement = this.currentClipboardObject as AnimationSequencer; List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(seqElement.AnimationElements); if (!(elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference?.Ability == destinationSequence); }))) { canPaste = true; } } else if (this.currentClipboardObject is ReferenceElement) { ReferenceElement refAbility = this.currentClipboardObject as ReferenceElement; if (refAbility.Reference?.Ability == destinationSequence) { canPaste = false; } else if (refAbility.Reference?.Ability?.AnimationElements != null && refAbility.Reference?.Ability?.AnimationElements.Count > 0) { bool refexists = false; if (refAbility.Reference.Ability.AnimationElements.Contains(destinationSequence as AnimationElement)) { refexists = true; } List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(refAbility.Reference.Ability.AnimationElements); if (elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); })) { refexists = true; } if (!refexists) { canPaste = true; } } else { canPaste = true; } } else { canPaste = true; } } break; case ClipboardAction.Cut: if (this.currentClipboardObject != null) { object[] clipObj = this.currentClipboardObject as object[]; AnimationElement clipboardAnimationElement = clipObj[0] as AnimationElement; AnimationSequencer clipboardAnimationSequencer = clipObj[1] as AnimationSequencer; if (clipboardAnimationElement is SequenceElement) { SequenceElement seqElement = clipboardAnimationElement as SequenceElement; List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(seqElement.AnimationElements); if (!(elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); }))) { canPaste = true; } } else if (clipboardAnimationElement is ReferenceElement) { ReferenceElement refAbility = clipboardAnimationElement as ReferenceElement; if (refAbility.Reference?.Ability == destinationSequence) { canPaste = false; } else if (refAbility.Reference?.Ability?.AnimationElements != null && refAbility.Reference?.Ability?.AnimationElements.Count > 0) { bool refexists = false; if (refAbility.Reference.Ability.AnimationElements.Contains(destinationSequence as AnimationElement)) { refexists = true; } List <AnimationElement> elementList = AnimationSequencerImpl.GetFlattenedAnimationList(refAbility.Reference.Ability.AnimationElements); if (elementList.Where((an) => { return(an.AnimationElementType == AnimationElementType.Reference); }).Any((an) => { return((an as ReferenceElement).Reference.Ability == destinationSequence); })) { refexists = true; } if (!refexists) { canPaste = true; } } else { canPaste = true; } } else { canPaste = true; } } break; } return(canPaste); }
public static List <int> Solve(int[] array) { List <int> result = new List <int>(); int n = array.Length; SequenceElement[] elements = new SequenceElement[n]; for (int i = n - 1; i >= 0; i--) { elements[i] = new SequenceElement(); for (int j = i + 1; j < n; j++) { if (array[j] > array[i] && elements[i].LengthUp < elements[j].LengthDown + 1) { elements[i].LengthUp = elements[j].LengthDown + 1; elements[i].NextPositionUp = j; } if (array[j] < array[i] && elements[i].LengthDown < elements[j].LengthUp + 1) { elements[i].LengthDown = elements[j].LengthUp + 1; elements[i].NextPositionDown = j; } } } int start = 0; bool up = true; int length = 0; for (int i = 0; i < n; i++) { if (elements[i].LengthUp > length) { length = elements[i].LengthUp; up = true; start = i; } if (elements[i].LengthDown > length) { length = elements[i].LengthDown; up = false; start = i; } } while (start != -1) { result.Add(array[start]); if (up) { start = elements[start].NextPositionUp; } else { start = elements[start].NextPositionDown; } up = !up; } return(result); }