Click here to Skip to main content
15,885,366 members

George L. Jackson - Professional Profile



Summary

Follow on Twitter      Blog RSS
6,544
Authority
629
Debator
6
Editor
42
Enquirer
2,615
Organiser
2,909
Participant
0
Author
M.A., Penn State

Reputation

Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.


 
GeneralExample of Creating a Collection in C++/CLI with a Built-in Predicate Pin
George L. Jackson3-Aug-07 14:25
George L. Jackson3-Aug-07 14:25 
#include < vector >
#include < algorithm >
 
using std::vector;
using std::find;
 
using namespace System;
using namespace System::Collections::Generic;
 
ref class IntVector : ICollection< int >
{
public:
	IntVector() : pVector(new vector< int >){}
 
	~IntVector() 
	{
		this->!IntVector();
	}
 
	!IntVector() 
	{
		if (pVector != IntPtr::Zero)
		{
			delete static_cast< vector< int >* >(
				pVector.ToPointer());
 
			pVector = IntPtr::Zero;
		}
	}
 
	property int Count
	{
		virtual int get();
	}
 
	property bool IsReadOnly
	{
		virtual bool get();
	}
 
	virtual void Add(int item);
	virtual void Clear();
	virtual bool Contains(int item);
	virtual void CopyTo (array< int >^ array, int arrayIndex);
	virtual bool Remove(int item);
 
	virtual IEnumerator< int >^ GetEnumerator();
 
	List< int >^ FindAll(Predicate< int >^ match)
	{
		if (match == nullptr)
			throw gcnew NullReferenceException();
 
		List< int >^ list = gcnew List< int >;
 
		for each(int value in this)
		{
			if (match(value))
				list->Add(value);
		}				
 
		return list;
	}
 
protected:
	ref class IntVectorCollection : IEnumerator< int >
	{
	public:
		IntVectorCollection(IntPtr vect) : pVector(vect), 
			index(0), IsReset(true) {}
 
		~IntVectorCollection() {}
 
		property int Current
		{
			virtual int get();
		}
 
		virtual bool MoveNext(void);
		virtual void Reset(void);
	private:
		property Object^ UnTypedCurrent
		{
			virtual Object^ get(void) 
				sealed = System::Collections::IEnumerator::Current::get;
		}
 
		IntPtr pVector;
		unsigned int index;
		bool IsReset;
	};
 
private:
	virtual System::Collections::IEnumerator^ GetUntypedEnumerator(void) 
		sealed = System::Collections::IEnumerable::GetEnumerator;
 
	IntPtr pVector;
};
 
Object^ IntVector::IntVectorCollection::UnTypedCurrent::get()
{
	vector< int >* ptr = static_cast< vector< int >* >(pVector.ToPointer());
 
	if (IsReset == true || index >= ptr->size())
	{
		throw gcnew System::ArgumentOutOfRangeException();
	}
 
	return (*ptr)[index];
}
 
bool IntVector::IntVectorCollection::MoveNext( void )
{
	if (IsReset)
		IsReset = false;
	else
		index++;
 
	return (index < static_cast< vector< int >* >(
		pVector.ToPointer())->size());
}
 
void IntVector::IntVectorCollection::Reset( void )
{
	index = 0;
	IsReset = true;
}
 
int IntVector::IntVectorCollection::Current::get()
{
	vector< int >* ptr = static_cast< vector< int >* >(pVector.ToPointer());
 
	if (IsReset == true || index >= ptr->size())
	{
		throw gcnew System::ArgumentOutOfRangeException();
	}
 
	return (*ptr)[index];
}
 
void IntVector::Add( int item )
{
	static_cast< vector< int >* >(
		pVector.ToPointer())->push_back(item);
}
 
void IntVector::Clear()
{
	static_cast< vector< int >* >(
		pVector.ToPointer())->clear();
}
 
bool IntVector::Contains( int item )
{
	vector< int >::iterator result;
	vector< int >* ptr = static_cast< vector< int >* >(pVector.ToPointer());
 
	result = find(ptr->begin(), ptr->end(), item);
 
	return result != ptr->end();
}
 
void IntVector::CopyTo( array< int >^ array, int arrayIndex )
{
	vector< int >* ptr =
		static_cast< vector< int >* >(pVector.ToPointer());
 
	for (unsigned int i = 0; i < ptr->size(); ++i)
	{
		array[arrayIndex++] = (*ptr)[i];
	}
}
 
bool IntVector::Remove( int item )
{
	vector< int >::iterator result;
	vector< int >* ptr = static_cast< vector< int >* >(pVector.ToPointer());
 
	result = find(ptr->begin(), ptr->end(), item);
 
	if (result == ptr->end()) return false;
 
	ptr->erase(result);
 
	return true;
}
 
IEnumerator< int >^ IntVector::GetEnumerator()
{
	return gcnew IntVectorCollection(pVector);
}
 
System::Collections::IEnumerator^ IntVector::GetUntypedEnumerator( void )  
{
	return gcnew IntVectorCollection(pVector);
}
 
int IntVector::Count::get()
{
	return static_cast< vector< int >* >(
		pVector.ToPointer())->size();
}
 
bool IntVector::IsReadOnly::get()
{
	return false;
}
 
ref class CompareInt
{
public:
	CompareInt(int value) : filter(value) {}
 
	bool IsLessThan(int value)
	{
		return value <  filter;	
	}
private:
	int filter;
};
 
int main(array< System::String ^ > ^args)
{
	IntVector^ vctr = gcnew IntVector;
 
	vctr->Add(10);
	vctr->Add(20);
	vctr->Add(30);
	vctr->Add(40);
	vctr->Add(50);
	vctr->Add(60);
	vctr->Add(70);
	vctr->Add(80);
	vctr->Add(90);
	vctr->Add(100);
 
	for each (int value in vctr)
	{
		Console::WriteLine(value);
	}
 
	Console::WriteLine();
 
	if (vctr->Remove(30))
	{
		for each (int value in vctr)
		{
			Console::WriteLine(value);
		}
	}
 
	Console::WriteLine();
 
	List< int >^ values =
		vctr->FindAll(gcnew Predicate< int >(
		gcnew CompareInt(60), &CompareInt::IsLessThan));
 
	for each (int value in values)
	{
		Console::WriteLine(value);
	}
 
    return 0;
}




"We make a living by what we get, we make a life by what we give." --Winston Churchill

GeneralC++/CLI and Inheriting from Generic Interfaces Pin
George L. Jackson3-Aug-07 13:47
George L. Jackson3-Aug-07 13:47 
GeneralC++/CLI and System.Predicate delegate [modified] Pin
George L. Jackson18-Jul-07 15:34
George L. Jackson18-Jul-07 15:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.