This commit is contained in:
Frank
2020-02-12 16:44:01 +01:00
parent b7543f24e8
commit 004591f8ad
6 changed files with 298 additions and 138 deletions
+102 -7
View File
@@ -37,7 +37,7 @@
-- ===
--
-- ### Author: **FlightControl**
-- ### Contributions:
-- ### Contributions: **funkyfranky**
--
-- ===
--
@@ -48,9 +48,10 @@
do -- SET_BASE
--- @type SET_BASE
-- @field #table Filter
-- @field #table Set
-- @field #table List
-- @field #table Filter Table of filters.
-- @field #table Set Table of objects.
-- @field #table Index Table of indicies.
-- @field #table List Unused table.
-- @field Core.Scheduler#SCHEDULER CallScheduler
-- @extends Core.Base#BASE
@@ -77,6 +78,10 @@ do -- SET_BASE
Set = {},
List = {},
Index = {},
Database = nil,
CallScheduler=nil,
TimeInterval=nil,
YieldInterval=nil,
}
@@ -224,8 +229,8 @@ do -- SET_BASE
--- Adds a @{Core.Base#BASE} object in the @{Core.Set#SET_BASE}, using a given ObjectName as the index.
-- @param #SET_BASE self
-- @param #string ObjectName
-- @param Core.Base#BASE Object
-- @param #string ObjectName The name of the object.
-- @param Core.Base#BASE Object The object itself.
-- @return Core.Base#BASE The added BASE Object.
function SET_BASE:Add( ObjectName, Object )
self:F2( { ObjectName = ObjectName, Object = Object } )
@@ -234,9 +239,14 @@ do -- SET_BASE
if self.Set[ObjectName] then
self:Remove( ObjectName, true )
end
-- Add object to set.
self.Set[ObjectName] = Object
-- Add Object name to Index.
table.insert( self.Index, ObjectName )
-- Trigger Added event.
self:Added( ObjectName, Object )
end
@@ -253,6 +263,81 @@ do -- SET_BASE
end
--- Get the *union* of two sets.
-- @param #SET_BASE self
-- @param Core.Set#SET_BASE SetB Set *B*.
-- @return Core.Set#SET_BASE The union set, i.e. contains objects that are in set *A* **or** in set *B*.
function SET_BASE:GetSetUnion(SetB)
local union=SET_BASE:New()
for _,ObjectA in pairs(self.Set) do
union:AddObject(ObjectA)
end
for _,ObjectB in pairs(SetB.Set) do
union:AddObject(ObjectB)
end
return union
end
--- Get the *intersection* of this set, called *A*, and another set.
-- @param #SET_BASE self
-- @param Core.Set#SET_BASE SetB Set other set, called *B*.
-- @return Core.Set#SET_BASE A set of objects that is included in set *A* **and** in set *B*.
function SET_BASE:GetSetIntersection(SetB)
local intersection=SET_BASE:New()
local union=self:GetSetUnion(SetB)
for _,Object in pairs(union.Set) do
if self:IsIncludeObject(Object) and SetB:IsIncludeObject(Object) then
intersection:AddObject(intersection)
end
end
return intersection
end
--- Get the *complement* of two sets.
-- @param #SET_BASE self
-- @param Core.Set#SET_BASE SetB Set other set, called *B*.
-- @return Core.Set#SET_BASE The set of objects that are in set *B* but **not** in this set *A*.
function SET_BASE:GetSetComplement(SetB)
local complement=SET_BASE:New()
local union=self:GetSetUnion(SetA, SetB)
for _,Object in pairs(union.Set) do
if SetA:IsIncludeObject(Object) and SetB:IsIncludeObject(Object) then
intersection:Add(intersection)
end
end
return intersection
end
--- Compare two sets.
-- @param #SET_BASE self
-- @param Core.Set#SET_BASE SetA First set.
-- @param Core.Set#SET_BASE SetB Set to be merged into first set.
-- @return Core.Set#SET_BASE The set of objects that are included in SetA and SetB.
function SET_BASE:CompareSets(SetA, SetB)
for _,ObjectB in pairs(SetB.Set) do
if SetA:IsIncludeObject(ObjectB) then
SetA:Add(ObjectB)
end
end
return SetA
end
@@ -712,7 +797,7 @@ do -- SET_BASE
--end
--- Decides whether to include the Object
--- Decides whether to include the Object.
-- @param #SET_BASE self
-- @param #table Object
-- @return #SET_BASE self
@@ -721,6 +806,16 @@ do -- SET_BASE
return true
end
--- Decides whether to include the Object.
-- @param #SET_BASE self
-- @param #table Object
-- @return #SET_BASE self
function SET_BASE:IsInSet(ObjectName)
self:F3( Object )
return true
end
--- Gets a string with all the object names.
-- @param #SET_BASE self