AVL tree/Managed C++: Difference between revisions

m
→‎Code: Fixed syntax highlighting.
m (→‎Code: Fixed syntax highlighting.)
 
(9 intermediate revisions by 3 users not shown)
Line 1:
== =Code ===
<syntaxhighlight lang ="cpp">// AVL in Managed C++
// AVL in Managed C++
 
using namespace System;
using namespace System;
using namespace System::Collections;
Line 11 ⟶ 9:
using namespace System::Runtime::Serialization;
 
namespace ISharpCalculus
{
 
Line 164 ⟶ 162:
generic<typename T>
Cloner<T>^ Cloner<T>::Invisible::get() { return gcnew DefaultNoCloner<T>(); }
 
public ref struct OutOfKeyOrderException : public Exception
{
Line 170 ⟶ 169:
OutOfKeyOrderException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 181 ⟶ 180:
TreeInvalidParentException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 192 ⟶ 191:
TreeOutOfBalanceException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 203 ⟶ 202:
InvalidEmptyTreeException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 215 ⟶ 214:
InvalidEndItemException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 226 ⟶ 225:
EntryAlreadyExistsException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 237 ⟶ 236:
DifferentKeysException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 248 ⟶ 247:
AddSubTreeFailedException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 259 ⟶ 258:
IsEndItemException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("ISharp CollectionsCalculus Subsystem");
}
};
Line 270 ⟶ 269:
EntryNotFoundException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 281 ⟶ 280:
InvalidSetOperationException() : Exception(message)
{
HelpLink = gcnew String("mailBenedict@BenedictBedeNNcNannara.comnet");
Source = gcnew String("StandardGenericLibrary CollectionsCalculus Subsystem");
}
};
Line 1,015 ⟶ 1,014:
Header = gcnew Node();
TComparer = System::Collections::Generic::Comparer<T>::Default;
TCloner = ISharpCalculus::Cloner<T>::Default;
THasher = ISharpCalculus::Hasher<T>::Default;
}
 
Line 1,024 ⟶ 1,023:
Header = gcnew Node();
TComparer = TCompare;
TCloner = ISharpCalculus::Cloner<T>::Default;
THasher = ISharpCalculus::Hasher<T>::Default;
}
 
Line 1,043 ⟶ 1,042:
Header = gcnew Node();
TComparer = System::Collections::Generic::Comparer<T>::Default;
TCloner = ISharpCalculus::Cloner<T>::Default;
THasher = ISharpCalculus::Hasher<T>::Default;
 
for each (T t in Collection) Add(TCloner->Clone(t));
Line 1,054 ⟶ 1,053:
Header = gcnew Node();
TComparer = System::Collections::Generic::Comparer<T>::Default;
TCloner = ISharpCalculus::Cloner<T>::Default;
THasher = ISharpCalculus::Hasher<T>::Default;
 
for each (T t in Collection) Add(TCloner->Clone(t));
Line 1,066 ⟶ 1,065:
Header = gcnew Node();
TComparer = TCompare;
TCloner = ISharpCalculus::Cloner<T>::Default;
THasher = ISharpCalculus::Hasher<T>::Default;
for each (T t in Collection) Add(TCloner->Clone(t));
Line 1,088 ⟶ 1,087:
Nodes=0;
System::Collections::Generic::IComparer<T>^ TCompare = (System::Collections::Generic::IComparer<T>^)si->GetValue("TComparer", System::Collections::Generic::IComparer<T>::typeid);
ISharpCalculus::ICloner<T>^ TClone = (ISharpCalculus::ICloner<T>^)si->GetValue("TCloner", ICloner<T>::typeid);
ISharpCalculus::IHasher<T>^ THasher = (ISharpCalculus::IHasher<T>^)si->GetValue("THasher", IHasher<T>::typeid);
 
Header = gcnew Node();
Line 1,395 ⟶ 1,394:
virtual void GetObjectData(SerializationInfo^ si, StreamingContext sc)
{
si->SetType(ISharpCalculus::Set<T>::typeid);
 
Type^ type = T::typeid;
Line 2,014 ⟶ 2,013:
{
System::Collections::Generic::IComparer<T>^ TComparer = R->TComparer;
ISharpCalculus::ICloner<T>^ TCloner = R->TCloner;
 
SetEntry<T> first1 = A->Begin;
Line 2,246 ⟶ 2,245:
}
 
using namespace ISharpCalculus;
 
int main(array<System::String ^> ^args)
{
Set<int>^ S = gcnew Set<int>(1, 3, 5 , 6, 7, 9);
Set<int>^ T = gcnew Set<int>(2, 4, 6 , 7, 8, 9);
Console::WriteLine(S.ToString());
Set<int>^ U = S | T;
Console::WriteLine(S.ToString() + " | " + T + " == " + U);
return 0;
}
</syntaxhighlight>
</lang>
9,476

edits