using System;
using System.Collections.Generic;
using UnityEngine;

namespace mgaia.Utils
{
    /// <summary>
    /// Extensões da tupla TimeAndStruct
    /// </summary>
    /// <owner>Victor</owner>
    public static class TimeAndValueExtensions
    {
        /// <summary>
        /// Retorna todos os tempos
        /// </summary>
        public static float[] GetTimes<T>(this TimeAndValue<T>[] timeAndValues) where T : struct
        {
			List<float> times = new List<float> ();
            
			foreach (TimeAndValue<T> timeAndValue in timeAndValues)
			{
				times.Add(timeAndValue.Time);
			}

			return times.ToArray();
        }

        /// <summary>
        /// Retorna todas os valores
        /// </summary>
        public static ValueType[] GetValues<T>(this TimeAndValue<T>[] timeAndValues) where T : struct
        {
			List<ValueType> values = new List<ValueType>();

			foreach(TimeAndValue<T> timeAndValue in timeAndValues)
			{
				values.Add(timeAndValue.Value);
			}

			return values.ToArray();
        }

        /// <summary>
        /// Retorna o primeiro valor
        /// </summary>
        public static T GetFirstValue<T>(this TimeAndValue<T>[] timeAndValues) where T : struct
        {
            return timeAndValues[0].Value;
        }
    }
}