<commit_before>/*
 * License
 */
package org.igniterealtime.xiff.data.im
{
	/*
	 * Copyright (C) 2008
	 * <NAME>

	 */
	 
	import mx.collections.ArrayCollection;
	import mx.collections.Sort;
	import mx.collections.SortField;
	
	public class RosterGroup extends ArrayCollection
	{
		public var label:String;
		public var shared:Boolean = false;
		
		public function RosterGroup(l:String)
		{
			var s:Sort = new Sort();
		    s.fields = [new SortField("displayName", true)];
		    sort = s;
		    refresh();
			label = l;
		}
		
		public override function addItem(item:Object):void
		{
			if(!item is RosterItemVO)
				throw new Error("Assertion Failure: attempted to add something other than a RosterItemVO to a RosterGroup");
			if(source.indexOf(item) == -1)
				super.addItem(item);
		}
		
		public function removeItem(item:RosterItemVO):void
		{
			var itemIndex:int = getItemIndex(item);
			if(itemIndex >= 0)
				removeItemAt(itemIndex);
			else
			{
				itemIndex =	source.indexOf(item);
				if(itemIndex >= 0)
					source.splice(itemIndex, 1);
			}
		}
		
		public override function set filterFunction(f:Function):void
		{
			throw new Error("Setting the filterFunction on RosterGroup is not allowed; Wrap it in a ListCollectionView and filter that.");
		}

		private function sortContacts(item1:RosterItemVO, item2:RosterItemVO, fields:Array = null):int
		{
			if(item1.displayName.toLowerCase() < item2.displayName.toLowerCase())
				return -1;
			else if(item1.displayName.toLowerCase() > item2.displayName.toLowerCase())
				return 1;
			return 0;
		}
	}
}<commit_msg>Removed the use of ArrayCollection in RosterGroup.<commit_after>/*
 * License
 */
package org.igniterealtime.xiff.data.im
{
	/**
	 * Represents the groups in users roster.
	 */
	public class RosterGroup
	{
		public var label:String;
		public var shared:Boolean = false;
		
		private var _items:Array = [];
		
		/**		
		 * Create a new group with the given name	
		 * @param	name	
		 */		
		public function RosterGroup(name:String)	
		{
			label = name;
		}
		
		/**
		 * Insert a new roster item if it does not already exists in this group	
		 * @param	item
		 */	
		public function addItem(item:RosterItemVO):void	
		{
			if (_items.indexOf(item) == -1)
			{
				_items.push(item);
			}
		}
		
		/**		
		 * Remove the given roster item from this group.
		 * @param	item		
		 */		
		public function removeItem(item:RosterItemVO):void
		{
			var index:int = _items.indexOf(item);
			if (index != -1)
			{
				_items.splice(index, 1);
			}
		}
		
		/**
		 * Does the given item exists in this group?
		 * @param	item
		 * @return		
		 */		
		public function contains(item:RosterItemVO):Boolean	
		{
			var value:Boolean = false;
			var index:int = _items.indexOf(item);	
			if (index != -1)	
			{			
				value = true;	
			}		
			return value;	
		}
		
		/**
		 * Roster items in this group.	
		 */	
		public function get items():Array
		{
			return _items;
		}
	}
}
{'fraction_non_alphanumeric': 0.11454792658055744, 'fraction_numerical': 0.007138001359619306, 'mean_word_length': 2.847058823529412, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1210651', 'n_tokens_mistral': 1189, 'n_tokens_neox': 964, 'n_words': 249}