aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs108
1 files changed, 0 insertions, 108 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
deleted file mode 100644
index fb9569e..0000000
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/FindallAnswers.cs
+++ /dev/null
@@ -1,108 +0,0 @@
1/*
2 * Copyright (C) 2007-2008, Jeff Thompson
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31using System;
32using System.Collections;
33using System.Collections.Generic;
34
35namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
36{
37 /// <summary>
38 /// A FindallAnswers holds answers for findall.
39 /// </summary>
40 public class FindallAnswers
41 {
42 private object _template;
43 private List<object> _bagArray;
44
45 public FindallAnswers(object Template)
46 {
47 _template = Template;
48 _bagArray = new List<object>();
49 }
50
51 public void add()
52 {
53 _bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
54 }
55
56 public List<object> resultArray()
57 {
58 return _bagArray;
59 }
60
61 /// <summary>
62 /// Unify Bag with the result. This frees the internal answers, so you can only call this once.
63 /// </summary>
64 /// <param name="Bag"></param>
65 /// <returns></returns>
66 public IEnumerable<bool> result(object Bag)
67 {
68 object result = ListPair.make(_bagArray);
69 // Try to free the memory.
70 _bagArray = null;
71 return YP.unify(Bag, result);
72 }
73
74 // disable warning on l1, don't see how we can
75 // code this differently
76 #pragma warning disable 0168, 0219
77
78 /// <summary>
79 /// This is a simplified findall when the goal is a single call.
80 /// </summary>
81 /// <param name="Template"></param>
82 /// <param name="goal"></param>
83 /// <param name="Bag"></param>
84 /// <returns></returns>
85 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag)
86 {
87 FindallAnswers findallAnswers = new FindallAnswers(Template);
88 foreach (bool l1 in goal)
89 findallAnswers.add();
90 return findallAnswers.result(Bag);
91 }
92
93 /// <summary>
94 /// Like findall, except return an array of the results.
95 /// </summary>
96 /// <param name="template"></param>
97 /// <param name="goal"></param>
98 /// <returns></returns>
99 public static List<object> findallArray(object Template, IEnumerable<bool> goal)
100 {
101 FindallAnswers findallAnswers = new FindallAnswers(Template);
102 foreach (bool l1 in goal)
103 findallAnswers.add();
104 return findallAnswers.resultArray();
105 }
106 #pragma warning restore 0168, 0219
107 }
108}