예제 #1
0
	vector<int> merge_sort(const vector<int>& input)
	{
		if(input.size()<=1) return input;
		vector<int> output(input.size());
	 
		//Split Vector//
		int midpoint=0.5*input.size();
		vector<int> input_left(input.begin(),input.begin()+midpoint);
		vector<int> input_right(input.begin()+midpoint,input.end());
	 
		input_left=merge_sort(input_left);
		input_right=merge_sort(input_right);
		merge(input_left.begin(),input_left.end(),input_right.begin(),input_right.end(),output.begin());
	 
		return output;
	}
예제 #2
0
int					handle_input(t_env *e, char *input)
{
	if (ft_strncmp(input, K_ESC, BUFFSIZE) == 0)
		input_exit();
	else if (is_enter(input))
		return (0);
	else if (is_del(input) && !input_del(e))
		return (0);
	else if (ft_strncmp(input, K_TOP, BUFFSIZE) == 0)
		e->current_index--;
	else if (ft_strncmp(input, K_BOTTOM, BUFFSIZE) == 0)
		e->current_index++;
	else if (ft_strncmp(input, K_RIGHT, BUFFSIZE) == 0)
		input_right(e);
	else if (ft_strncmp(input, K_LEFT, BUFFSIZE) == 0)
		input_left(e);
	else if (ft_strncmp(input, K_SPACE, BUFFSIZE) == 0)
		input_space(e);
	if (e->current_index < 0
			|| e->current_index > e->chain_size - e->deleted - 1)
		e->current_index = (e->current_index + e->chain_size - e->deleted)
							% (e->chain_size - e->deleted);
	return (1);
}